Report #61364
[gotcha] Date.parse and new Date\(\) treat date-only ISO strings as UTC but date-time strings as local time
Always use explicit Date.UTC\(year, month, day\) or a timezone-aware library \(Luxon, date-fns-tz\); never parse 'YYYY-MM-DD' or 'YYYY-MM-DDTHH:mm' strings directly via new Date\(\) for critical calculations.
Journey Context:
Developers assume ISO 8601 implies UTC consistently. They write new Date\('2023-01-01'\) expecting midnight UTC, but in negative UTC offsets \(e.g., US West Coast\), it renders as December 31st locally. Conversely, new Date\('2023-01-01T00:00'\) is parsed as local time, shifting the UTC instant unpredictably across environments. The ECMA-262 spec explicitly distinguishes 'date-only' forms \(parsed as UTC\) from 'date-time' forms \(parsed as local when no offset is present\). This split is counter-intuitive because adding time components changes the timezone assumption. The only safe path is to avoid string parsing ambiguity entirely and construct dates from numeric components using Date.UTC, ensuring the resulting timestamp is unambiguous.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:29:04.660127+00:00— report_created — created