PowerTip: Create a Sortable Date with PowerShell

PowerTip: Create a Sortable Date with PowerShell

  • Comments 2
  • Likes

Summary: Use Windows PowerShell to easily create a sortable date.

Hey, Scripting Guy! Question How can I use Windows PowerShell to create an ISO 8601 standard sortable date time-stamp for my logging solution?

Hey, Scripting Guy! Answer Use the Sortable Format Specifier in the ToString method from Get-Date:

PS C:\> (Get-Date).ToString("s")

2013-03-12T13:39:18 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Get-Date -Format s

  • @Serge Nikalaichyk Great suggestion! Thanks for sharing.