Bug introduced in V10.4 or earlier and persisting through 12.3.0
(CASE:3920785)
Back in version 10.2 or so, Mathematica began supporting the ISO 8601 date/time format, which is nice because it's used pretty frequently. You can target the format with DateString
:
DateString["ISODateTime"]
(* "2017-04-28T11:45:14" *)
which was the current time when I typed that. You can import from a string using DateObject
, like so:
DateObject["2017-04-28T11:45:14"]
(* DateObject[{2017, 4, 28, 11, 45, 14}, "Instant", "Gregorian", -4.] *)
The last element there is the time zone, which defaults to $SystemTimeZone
, will be important later. It looks prettier in StandardForm
. However, I had an externally generated string:
isoDateString = "2017-04-28T01:50:52.000Z";
If you look at the doubtless highly authoritative Wikipedia article, you'll see that the "Z"
at the end there means that it should be UTC time, or in Mathematica parlance, it should have 0
for its time zone. Sadly, no!
DateObject[isoDateString]
(* DateObject[{2017, 4, 28, 1, 50, 52.}, "Instant", "Gregorian", -4.] *)
It's still using the default time zone! Is there any way to correct this that doesn't require manual string munging?
FromDateString
in 12.3? $\endgroup$