我需要将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
我该怎么做?
PowerShellGet-Date支持标准.NET时间格式。在o往返格式符合ISO 8601。像这样,
Get-Date
o
Get-Date -Format "o" 2017-08-15T12:10:34.4443084+03:00
尽管存在可能的可移植性问题,但我还是喜欢此解决方案,因为它很简单,您基本上可以将其存储在快速编写的脚本中。