PowerTip: Use UNIX Date Formatting in PowerShell

PowerTip: Use UNIX Date Formatting in PowerShell

  • Comments 2
  • Likes

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


Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • %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

  • Get the Epoch: www.coolepochcountdown.com