3 ms·
Talking about dates and Safari, be aware of this in JavaScript. new Date('12-27-2022'); works in Chrome but returns an invalid date in Safari & FireFox. new D
by dutchbrit 4y ago
Talking about dates and Safari, be aware of this in JavaScript.
new Date('12-27-2022'); works in Chrome but returns an invalid date in Safari & FireFox.
new Date('12/27/2022'); works for all browsers.
- masklinn 4y agoThe first format makes no fucking sense to start with, the US is the main country which uses mid-endian dates and it doesn't use "-" as a separator. But beyond that, don't use `new Date(string)`: the only spec-defined format is a restricted ISO 8601[0], though the horror show that is RFC 2822 datetimes is conventionally supported by everybody because it's the standard stringification (Date#toString). Everything else is implementation-defined, and likely heuristic. [0] https://tc39.es/ecma262/#sec-date-time-string-format https://tc39.es/ecma262/#sec-date-time-string-format