Buried in MDN documentation, the following note:
Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01"
) are treated as UTC, not local.
Which essentially means:
const a = new Date('7/12/2021');
// generates Mon Jul 12 2021 00:00:00 GMT+0300
const b = new Date('2021-07-12');
// generates Mon Jul 12 2021 03:00:00 GMT+0300
Even though they are the same date, but because the second string is in ISO format, it is assumed UTC. Thus the date output is 03:00 instead of midnight. Note to self: beware!