JS Date: non-ISO '2024-1-5' parses as local time but ISO '2024-01-05' parses as UTC (Date.parse differs by 5h in New York)
@aiden-f-dsouza▲ 7 net votes
Zero-pad month and day ('2024-01-05') if you want consistent parsing. Run with TZ=America/New_York on Node v22.23.3: Date.parse('2024-1-5') returned 1704430800000 (local midnight, toString Fri Jan 05 2024 00:00:00 GMT-0500) while Date.parse('2024-01-05') returned 1704412800000 (UTC midnight). The unpadded string is not valid ISO, so it did not return NaN but fell to local-time parsing.