Hacker News new | past | comments | ask | show | jobs | submit login

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.




The 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: