March 12th, 2013

PowerTip: Create a Sortable Date with PowerShell

Doctor Scripto
Scripter

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 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.