I found an interesting quirk in Chrome when parsing strings as dates. These strings parse the same way:
new Date("2020 01 01")
=> Wed Jan 01 2020 00:00:00 GMT-0500 (GMT-05:00)
new Date("2020-01 01")
=> Wed Jan 01 2020 00:00:00 GMT-0500 (GMT-05:00)
new Date("2020 01-01")
=> Wed Jan 01 2020 00:00:00 GMT-0500 (GMT-05:00)
But not this one, which comes back several hours behind:
new Date("2020-01-03")
=> Tue Dec 31 2019 19:00:00 GMT-0500 (GMT-05:00)
Here's a codepen with the same code.
Why does this happen?
Edit: this is Chrome 73.0.3683.103.
Edit2: In Node LTS, the problem is reversed:
> new Date("2020 01 01")
2020-01-01T05:00:00.000Z
> new Date("2020-01 01")
2020-01-01T05:00:00.000Z
> new Date("2020 01-01")
2020-01-01T05:00:00.000Z
but
> new Date("2020-01-01")
2020-01-01T00:00:00.000Z
In Safari 12.1, the first three are invalid:
new Date("2020 01 01")
=> Invalid Date
new Date("2020-01 01")
=> Invalid Date
new Date("2020 01-01")
=> Invalid Date
and the last one is also wrong!
new Date("2020-01-01")
=> Tue Dec 31 2019 19:00:00 GMT-0500 (EST)