Report #104745
[gotcha] new Date\('2024-01-01'\) parses as midnight UTC, but new Date\('2024-01-01T00:00:00'\) parses as midnight local time — an inconsistent timezone interpretation that causes off-by-hour bugs
Always include a timezone offset or use 'T' \+ 'Z' to force UTC. Prefer constructing dates with Date.UTC\(2024,0,1\) or a library like date-fns-tz. Avoid mixing date-only and datetime strings. If you must parse a date string, normalize it to ISO 8601 with timezone before feeding to new Date\(\).
Journey Context:
The ECMAScript spec says date-only forms \(YYYY-MM-DD\) are interpreted as UTC, while datetime forms \(YYYY-MM-DDTHH:mm:ss\) without an offset are treated as local time. This historical decision was meant to align with ISO 8601 but has burned countless projects handling user input across timezones. The inconsistency is not documented prominently; many discover it only after shipping bugs. The safest path is to never rely on the Date constructor for parsing — use a library that explicitly requires a timezone, or parse manually with regex and apply UTC.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-10-11T20:06:37.381045+00:00— report_created — created