Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this format means T00:00:00.000Z?

Can someone, please, explain this type of format in javascript

 T00:00:00.000Z 

And how to parse it?

like image 484
Ali Akram Avatar asked Mar 09 '15 19:03

Ali Akram


People also ask

What is t00 00 00z?

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.

What does 000z mean in timestamp?

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.


1 Answers

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()); 
like image 100
nanndoj Avatar answered Sep 29 '22 16:09

nanndoj