Discovering Date and Time Culture Information

Share |

Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Powershell Plus

13 Free SQL Tools from Idera

Free Ebook: Mastering Powershell

PowerShell automatically converts date and time information in various formats. If you'd like to know what formats are recognized by PowerShell, how these formats are defined, and what else your current culture defines, here is a one-liner that dumps all of this:

PS> [System.Globalization.CultureInfo]::CurrentUICulture.DateTimeFormat

AMDesignator                     :
Calendar                         : System.Globalization.GregorianCalendar
DateSeparator                    : .
FirstDayOfWeek                   : Monday
CalendarWeekRule                 : FirstFourDayWeek
FullDateTimePattern              : dddd, d. MMMM yyyy HH:mm:ss
LongDatePattern                  : dddd, d. MMMM yyyy
LongTimePattern                  : HH:mm:ss
MonthDayPattern                  : dd MMMM
PMDesignator                     :
RFC1123Pattern                   : ddd, dd MMM yyyy HH':'mm':'ss 'GMT'
ShortDatePattern                 : dd.MM.yyyy
ShortTimePattern                 : HH:mm
SortableDateTimePattern          : yyyy'-'MM'-'dd'T'HH':'mm':'ss
TimeSeparator                    : :
UniversalSortableDateTimePattern : yyyy'-'MM'-'dd HH':'mm':'ss'Z'
YearMonthPattern                 : MMMM yyyy
AbbreviatedDayNames              : {So, Mo, Di, Mi...}
ShortestDayNames                 : {So, Mo, Di, Mi...}
DayNames                         : {Sonntag, Montag, Dienstag, Mittwoch...}
AbbreviatedMonthNames            : {Jan, Feb, Mrz, Apr...}
MonthNames                       : {Januar, Februar, März, April...}
IsReadOnly                       : False
NativeCalendarName               : Gregorianischer Kalender
AbbreviatedMonthGenitiveNames    : {Jan, Feb, Mrz, Apr...}
MonthGenitiveNames               : {Januar, Februar, März, April...}

Any format defined here is a legal date and time format.

Note: When you cast a string to a DateTime type, PowerShell always uses the culture-invariant format. Your own culture is honored when you use the -as operator. That's why these two lines may produce different results if you're not on the en-US culture:

PS> [DateTime] '10/1/2013'
Dienstag, 1. Oktober 2013 00:00:00

PS> '10/1/2013' -as [DateTime]
Donnerstag, 10. Januar 2013 00:00:00

Twitter This Tip! ReTweet this Tip!

Posted Feb 11 2013, 06:00 AM by ps1
Copyright 2012 All rights reserved.