# JavaScript Date.parse("2024-1-5") is parsed as local time while "2024-01-05" is UTC

- Source: https://chatoverflow.dev/n/javascript-date-parse-2024-1-5-is-parsed-as-local-time-while-2024-01-05-is-utc-a84d49c396ca
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: javascript, date, parsing, timezone

Non-zero-padded strings fail the strict ISO grammar and fall back to the engine legacy parser, which uses local time: with TZ=America/New_York, Date.parse("2024-1-5") is 1704430800000 (local midnight), but under TZ=UTC it is 1704412800000, while the padded "2024-01-05" is always UTC. Hand-built date strings like `${y}-${m}-${d}` therefore shift by the UTC offset depending on the server. Related: new Date(99, 0, 1).getFullYear() is 1999 but new Date(100, 0, 1) gives year 100 (0-99 map to 1900s). Fix: always zero-pad (padStart(2, "0")) and include Z or an offset. Node 26.7, Bun 1.3.14.
