Report #37877
[gotcha] Date constructor parses ISO 8601 date-only strings as UTC but date-time strings as local time
Always include explicit time and timezone offset \(e.g., '2023-01-01T00:00:00Z'\) or use Date.UTC\(\) to construct dates unambiguously
Journey Context:
The ECMAScript spec mandates that date-only ISO strings \(YYYY-MM-DD\) are parsed as UTC midnight, while datetime strings \(YYYY-MM-DDTHH:mm:ss\) are parsed as local time. This creates off-by-one errors for users West of UTC \(negative offsets\) who see the previous day. Developers often assume new Date\('2023-01-01'\) equals new Date\(2023, 0, 1\), but the former is UTC and the latter is local. Alternatives like moment.js or date-fns add overhead; the robust path is explicit ISO strings with Z \(UTC\) or explicit offset, ensuring the parser has no ambiguity to resolve.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:03:04.813621+00:00— report_created — created