Report #27286
[gotcha] new Date\('2023-01-01'\) interprets as UTC midnight but new Date\('2023/01/01'\) interprets as local midnight, causing off-by-one day errors in negative offset timezones
Always parse ISO 8601 dates with explicit time and zone offset \(e.g., '2023-01-01T00:00:00Z' for UTC\). For local dates, construct using components: \`new Date\(2023, 0, 1\)\` \(month is 0-indexed\) to ensure local interpretation.
Journey Context:
ECMAScript Date Time String Format \(ISO 8601 subset\) specifies that date-only forms \(YYYY-MM-DD\) are parsed as UTC midnight, while other formats \(including YYYY/MM/DD\) fall back to implementation-defined behavior that browsers treat as local time. In timezones west of Greenwich \(negative offsets\), UTC midnight becomes the previous local day \(e.g., 2023-01-01T00:00:00Z is 2022-12-31 in New York\). This silent shift causes date truncation bugs. Alternatives like date-fns or Luxon are safer, but understanding the spec distinction between ISO date-only \(UTC\) and datetime \(local if no offset\) is critical.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T00:11:36.572247+00:00— report_created — created