Windows ISO 8601 timestamp

我与影子孤独终老i 提交于 2020-01-31 07:07:07

问题


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?


回答1:


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



回答2:


Get-Date supports Unix formatting strings with the -UFormat parameter. You can reuse it:

Get-Date -UFormat '+%Y-%m-%dT%H:%M:%S.000Z'


来源:https://stackoverflow.com/questions/45689471/windows-iso-8601-timestamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!