Convert month to month name with PowerShell

I need to convert "08" to display "August"

I cannot use Get-Date , as this comes from a file name that may or may not change.

So, currently I am splitting the name into an array, accessing the data I need and I need to convert the mm section to MMMM

 01 = January 03 = March etc 
+15
datetime powershell
source share
4 answers

Full month name:

 (Get-Culture).DateTimeFormat.GetMonthName(8) 

Abbreviated:

 (Get-Culture).DateTimeFormat.GetAbbreviatedMonthName(8) 
+19
source share

If you are looking for the current month, try this:

 $currentMonth = Get-Date -UFormat %m $currentMonth = (Get-Culture).DateTimeFormat.GetMonthName($currentMonth) 
+3
source share
 (Get-Culture).DateTimeFormat.GetMonthName((Get-Date).Month) 
+1
source share

In the spirit of using the easiest way:

Get-Date -UFormat %B

or get a monthly reduction:

Get-Date -UFormat %b

It is also well tolerated with BASH and other scripting languages ​​that use this format for dates.

+1
source share

All Articles