Skip to content

Display date time using the local PCs setting


regional Setting on the local PC can be enumerated with the Get-Culture cmdlet. This is for example helpful if dates shall be displayed in the current PCs ordinary format. Instead assuming what might be the correct format , use the current configuration:

get-date -Format (get-culture).datetimeformat.shortdatepattern

if the separator char should be removed , because you need the date in filenames use the date separator property

(get-date -Format (get-culture).datetimeformat.shortdatepattern).replace( (get-culture).datetimeformat.dateseparator,””)

See all the properties that the DateTImeFormat property has:
 Get-Culture | select -ExpandProperty 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...}
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: