简体   繁体   中英

What type of date format is this and how to format it to human readable format?

What type of date format is this ?

+57432-03-28T16:01:10Z

I've tried using plain Javascript, daysjs and moment but I always get 'Invalid Date'. Did someone encounter this?

Also, I've been unable to find the following date formats on the web.

Looks like you are in the year 57432 whilst we are in 2019. Jokes apart, Add a 0 and it shall work.

new Date('+057432-03-28T16:01:10Z')

The reason being, ECMAScript requires a 6 digit year in order to support its year expansion feature.

This link explains it: http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15

Edit (as @RobG pointed out):

This link has the latest details: http://ecma-international.org/ecma-262/10.0/#sec-expanded-years

It looks like new Date().toISOString() format,but missing 0 after +. try new Date('+057432-03-28T16:01:10Z')

It's ISO_8601

You could use JavaScript's Date object to parse this date string.

new Date();
new Date(value);
new Date(dateString);
new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]]);

Other answers have pointed out that the date string missed a 0 after '+' which causes the date string invalid.

let bad = '+57432-03-28T16:01:10Z' // invalid
let d1 = new Date(bad);// Invalid Date {}
let good = '+057432-03-28T16:01:10Z' // valid
let d2 = new Date(good); // ok

Here is the similar question -> What is this date format? 2011-08-12T20:17:46.384Z

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM