PowerTip: Create a Sortable Date with PowerShell

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")


Comments (3)

  1. mredwilson says:

    @Serge Nikalaichyk Great suggestion! Thanks for sharing.

  2. Anne says:

    Powershell v4, the result is not sortable since it is in 12hr not 24hr hours.

Skip to main content