Get Localized Month Names

by May 18, 2012

To get a list of month names, you could use this line:

PS> [System.Enum]::GetNames([System.DayOfWeek])
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday

However, this returns a culture-neutral list which is not returning the month names in a localized (regional) form. To get the localized month names, use this line instead:

PS> 0..11 | 
  ForEach-Object { [Globalization.DatetimeFormatInfo]::CurrentInfo.MonthNames[$_] }
Januar
Februar
Marz
April
Mai
Juni
Juli
August
September
Oktober
November
Dezember

Twitter This Tip! ReTweet this Tip!