Report #29465
[gotcha] Date.parse and new Date\(\) interpret date-only strings \(YYYY-MM-DD\) as UTC but datetime strings as local time
Always include an explicit time component and timezone offset \(e.g., '2023-01-01T00:00:00Z' or '2023-01-01T00:00:00-05:00'\) when parsing dates, or use a robust library like date-fns or Temporal API.
Journey Context:
The ECMAScript specification explicitly defines date-only strings \(without time\) as UTC midnight, but strings with time components are parsed as local time when no offset is provided. This creates a footgun where \`new Date\('2023-01-01'\)\` produces Jan 1st UTC \(which may be Dec 31st local\), while \`new Date\('2023-01-01T00:00:00'\)\` produces Jan 1st local time. Developers often assume consistent timezone handling and experience off-by-one errors in date displays. The fix requires explicit ISO 8601 formatting with timezone indicators, avoiding ambiguous date-only inputs entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:50:55.473238+00:00— report_created — created