Warm tip: This article is reproduced from serverfault.com, please click

Windows ISO 8601 timestamp

发布于 2017-08-15 08:45:31

I need to convert a date in Windows PowerShell to the ISO 8601 format.

In Linux/Unix it was no problem with

TZ=0 date -d "<random-format>" +%Y-%m-%dT%H:%M:%S.000Z

Now I need to do the same in Windows PowerShell. The output format on Windows is

Wednesday, 19. July 2017 01:06:13

How can I do it?

Questioner
M.S.
Viewed
0
27.9k 2019-01-14 13:18:50

PowerShell's Get-Date supports standard .NET time formats. The o round-trip format complies with ISO 8601. Like so,

Get-Date -Format "o"

2017-08-15T12:10:34.4443084+03:00