You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Get-Date: format option for ISO 8601 in UTC #11410
First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
Get-Date should support ISO 8601 to return in UTC. Currently the -format s option returns in ISO 8601 but local time.
There should be a new option which formats including the timezone.
e.g. instead of 2019-12-20T08:48:05 in UTC +1, it should be 2019-12-20T07:48:05Z
S is a short cut for "SortableDateTimePattern" which is defined in the current culture.
It is equivalent to adding .tostring((Get-Culture).DateTimeFormat.SortableDateTimePattern)
The .Net formatter seems to do some odd things. e.g. [datetime]::now.tostring("r") Will append "GMT" to the converted date time regardless of the timezone it came from
[datetime]::now.tostring("HH:mm zzz") returns the offset information, e.g. 13:25 +01:00
But the formatter doesn't seem to have a method for converting local time to universal time or vice versa. It needs to be done before the formatting is applied. [datetime]::now.ToUniversalTime().tostring("HH:mm zzz")
Ideally Get-Date would have -UniversalTime as a switch.
Reacted by Michael Klement, Rain Sallow (/u/ta11ow) and finackninja
First-Time-IssueEasy issues first time contributors can work on to learn about this projectIssue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issues
Activity
jhoneill commentedon Dec 20, 2019
S is a short cut for "SortableDateTimePattern" which is defined in the current culture.
It is equivalent to adding .tostring((Get-Culture).DateTimeFormat.SortableDateTimePattern)
The .Net formatter seems to do some odd things. e.g.
[datetime]::now.tostring("r")Will append "GMT" to the converted date time regardless of the timezone it came from[datetime]::now.tostring("HH:mm zzz")returns the offset information, e.g. 13:25 +01:00But the formatter doesn't seem to have a method for converting local time to universal time or vice versa. It needs to be done before the formatting is applied.
[datetime]::now.ToUniversalTime().tostring("HH:mm zzz")Ideally Get-Date would have -UniversalTime as a switch.
iSazonov commentedon Dec 20, 2019
There is
Get-Date -Format FileDateTimeUniversal.The switch could be
-AsUTC.jackdcasey commentedon Jan 16, 2020
I'd be happy to take this one on!
OneCyrus commentedon Jan 25, 2020
awesome! thank you Brendan Burns (@brendandburns)!