PowerTip: Use UNIX Date Formatting in PowerShell

Summary:  Learn how to use UNIX date formatting in Windows PowerShell.

Hey, Scripting Guy! Question How can I use my prior knowledge of UNIX date formatting to specify dates in Windows PowerShell?

Hey, Scripting Guy! AnswerUse the Get-Date cmdlet and the –Uformat parameter. For example, to display a date in standard format for your current locale, use the “x” format specifier:

PS C:\> Get-Date -UFormat %x


Comments (3)

  1. Ben S says:

    %s being the switch to convert to epoch time. Then…

    Get-date $(Get-Date("10/07/1975 08:00")) -uFormat %s

    to get a given date in epoch time, and the following function to convert back to date time in local time zone.

    Function Get-DateFromEpoch ($EpochDate) {




    Thursday, 10 July 1975 4:00:00 PM

  2. Tarek says:

    Hi Scripting Guy
    How can I get local time from a string/integer containing Unix time ?

Skip to main content