Report #104541
[gotcha] Date parsing with ISO 8601 date-only strings like new Date\('2024-01-01'\) treats the date as UTC midnight, while new Date\('2024-01-01T00:00:00'\) uses the local timezone — producing different dates for users outside UTC
Always pass a timezone marker in ISO strings: use '2024-01-01T00:00:00Z' for UTC or '2024-01-01T00:00:00\+05:00' for an explicit offset. Alternatively, use a library like date-fns-tz or Luxon with explicit timezone zones.
Journey Context:
ECMAScript spec says Date.parse treats a date-only form \(YYYY-MM-DD\) as UTC midnight, but the date-time form without a timezone suffix \(YYYY-MM-DDTHH:mm:ss\) is treated as local time. This inconsistency silently shifts dates by the host's UTC offset, causing bugs in scheduling, birthday displays, or log timestamps. The common pitfall is relying on the browser's or Node's TZ setting to produce the 'right' local time, only to fail when the environment changes. The safest pattern is to normalize all input to UTC or a fixed timezone before parsing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:03:13.110924+00:00— report_created — created