What default time is Javascript new Date using if I only specify a date?

Viewed 657

new Date((new Date('1900-01-01')).getTime())
--> Sun Dec 31 1899 23:23:15 GMT-0036 (Western European Standard Time)

but I would expect the above to be the same as this:
new Date((new Date('1900-01-01T00:00')).getTime())
--> Mon Jan 01 1900 00:00:00 GMT-0036 (Western European Standard Time)

which is does for all dates after ~1912-01-01:
new Date((new Date('1912-01-01')).getTime())
--> Mon Jan 01 1912 00:00:00 GMT+0000 (Western European Standard Time)

even more weird:
new Date((new Date('1911-11-3')).getTime())
--> Fri Nov 03 1911 00:00:00 GMT-0036 (Western European Standard Time) BUT
new Date((new Date('1911-11-03')).getTime())
--> Thu Nov 02 1911 23:23:15 GMT-0036 (Western European Standard Time)

I know there are good reasons that Moment.js exists, but why on earth is there a difference in time with and without that leading zero in the date??

(new Date('1911-11-03')).getTime()
-1835481600000
(new Date('1911-11-3')).getTime()
-1835479395000
0 Answers
Related