JavaScript new Date (string) returns different results in exactly identical date strings

I would like to share what I found using JavaScript today.

Simple example here

d1 = "2014-07-15T14:00:00.000Z"
d2 = "2014-07-15T14:00:00.000Z"

ISO input lines are formatted with new Date().toISOString();. I got the first date from the server, where it was saved in mongoDB as ISOString, and the second was created manually.

If I do new Date(d1);, it returns "Invalid date", but if I do the same for d2, it will return the correct date.

+4
source share
1 answer

The first contains unprintable

0x20 0x3D 0x20 0x22

characters

+5
source

Source: https://habr.com/ru/post/1548292/


All Articles