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

powershell-Windows ISO 8601时间戳记

(powershell - Windows ISO 8601 timestamp)

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

我需要将Windows PowerShell中的日期转换为ISO 8601格式。

在Linux / Unix中,

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

现在,我需要在Windows PowerShell中执行相同的操作。Windows上的输出格式是

Wednesday, 19. July 2017 01:06:13

我该怎么做?

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

PowerShellGet-Date支持标准.NET时间格式。o往返格式符合ISO 8601。像这样,

Get-Date -Format "o"

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