header image

Date formats

Posted by: | June 8, 2011 | No Comment |

Can you remember all of the .NET date formats and what they mean.  I can’t so I wrote this reminder

"d ShortDatePattern                                                :  {0} " -f (get-date -Format d )
"D LongDatePattern                                                 :  {0} " -f (get-date -Format D )
"f Full date and time (long date and short time)                   :  {0} " -f (get-date -Format f )
"F FullDateTimePattern (long date and long time)                   :  {0} " -f (get-date -Format F )
"g General (short date and short time)                             :  {0} " -f (get-date -Format g )
"G General (short date and long time)                              :  {0} " -f (get-date -Format G )
"m MonthDayPattern                                                 :  {0} " -f (get-date -Format m )
"M MonthDayPattern                                                 :  {0} " -f (get-date -Format M )
"o Round-trip date/time pattern always uses the invariant culture  :  {0} " -f (get-date -Format o )
"O Round-trip date/time pattern always uses the invariant culture  :  {0} " -f (get-date -Format O )
"r RFC1123Pattern always uses the invariant culture                :  {0} " -f (get-date -Format r )
"R RFC1123Pattern always uses the invariant culture                :  {0} " -f (get-date -Format R )
"s SortableDateTimePattern always uses the invariant culture       :  {0} " -f (get-date -Format s )
"t ShortTimePattern                                                :  {0} " -f (get-date -Format t )
"T LongTimePattern                                                 :  {0} " -f (get-date -Format T )
"u UniversalSortableDateTimePattern                                :  {0} " -f (get-date -Format u )
"U Full date and time – universal time                             :  {0} " -f (get-date -Format u )
"y YearMonthPattern                                                :  {0} " -f (get-date -Format y )
"Y YearMonthPattern                                                :  {0} " -f (get-date -Format Y )

Run the script and get an easy reminder.

I’ll add something for the customised formats another time

under: PowerShellV2