PowerTip: Use PowerShell to Display date Format for Specific Culture


Summary: Learn how to use Windows PowerShell to display date formatting for a specific culture.

Hey, Scripting Guy! Question How can I use Windows PowerShell to see the short date pattern for a specific culture without
           changing my UI culture settings?

Hey, Scripting Guy! Answer Use the CultureInfo class from System.Globalization, call the GetCultureInfo static method
           while passing a culture number, and choose the ShortDatePattern property from the DateTime 
           format object, for example:

[System.Globalization.CultureInfo]::GetCultureInfo(1031).DateTimeFormat.ShortDatePattern

Comments (3)

  1. Exactly what I was looking for thx!

  2. Formats says:

    This too:

    PS >[System.Globalization.CultureInfo]::GetCultureInfo(1031).DateTimeFormat.ShortDatePattern
    dd.MM.yyyy
    PS >[System.Globalization.CultureInfo]::GetCultureInfo(‘en-US’).DateTimeFormat.ShortDatePattern
    M/d/yyyy
    PS >[System.Globalization.CultureInfo]::GetCultureInfo(‘fr-fr’).DateTimeFormat.ShortDatePattern
    dd/MM/yyyy
    PS >[System.Globalization.CultureInfo]::GetCultureInfo(‘en-GB’).DateTimeFormat.ShortDatePattern
    dd/MM/yyyy
    PS >
    PS >[System.Globalization.CultureInfo]::GetCultureInfo(‘de-DE’).DateTimeFormat.ShortDatePattern
    dd.MM.yyyy
    PS >

  3. Short method says:

    PS >[datetime]::Now.ToString([cultureinfo]’de-DE’)
    22.01.2015 16:17:55

Skip to main content