Can someone, please, explain this type of format in javascript
T00:00:00.000Z
And how to parse it?
The Z on the end means UTC (that is, an offset-from-UTC of zero hours-minutes-seconds). Also, that these default to 00:00:00 because time was not defined. This document can be used as reference.
The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC). What Z means in date? zero. What is a timestamp example? TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.
It's a part of ISO-8601 date representation. It's incomplete because a complete date representation in this pattern should also contains the date:
2015-03-04T00:00:00.000Z //Complete ISO-8601 date
If you try to parse this date as it is you will receive an Invalid Date
error:
new Date('T00:00:00.000Z'); // Invalid Date
So, I guess the way to parse a timestamp in this format is to concat with any date
new Date('2015-03-04T00:00:00.000Z'); // Valid Date
Then you can extract only the part you want (timestamp part)
var d = new Date('2015-03-04T00:00:00.000Z'); console.log(d.getUTCHours()); // Hours console.log(d.getUTCMinutes()); console.log(d.getUTCSeconds());
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