For instance,
const d = new Date("2012-08-20T15:00:00-07:00");
d
here is a UTC time with time offset = 07:00
. Does it still require Z
like this 2012-08-20T15:00:00-07:00Z
? Is this correct?
If I take this string with Z
and parse it using Date.parse()
method in JavaScript, it throws an error. Not sure what is wrong!
The UTC Time Format In other formats, UTC is replaced with Z, which is the zero UTC offset. For instance, UTC time in ISO-8601 is xx:xx:xxZ. The Z letter is added without a space. Another UTC format is a 12-hour clock time (AM/PM) xx:xx:xx.
The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC).
Local date and time values is an offset from UTC (for example, +01:00, -07:00). All DateTimeOffset values are also represented in this format. The time zone component of DateTimeKind. Utc date and time values uses "Z" (which stands for zero offset) to represent UTC.
UTC() is a static method of the Date object. The syntax is always Date. UTC().
No, you should not include the "Z" with a time zone offset.
From rfc3339:
Z A suffix which, when applied to a time, denotes a UTC
offset of 00:00; often spoken "Zulu" from the ICAO
phonetic alphabet representation of the letter "Z".
The "Z" is a zero time offset, so including it with an explicit offset (especially a non-zero one) doesn't makes sense.
Quoting W3C note on Date and Time Formats:
YYYY-MM-DDThh:mm:ss.sTZD (eg 1997-07-16T19:20:30.45+01:00)
where:
[...]
TZD = time zone designator (Z or +hh:mm or -hh:mm)
Notice the or word above. You either specify time zone offset or Z
for Zulu (no offset).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With