Report #94665
[gotcha] Date constructor parses 'YYYY-MM-DD' as UTC but 'YYYY-MM-DDTHH:mm:ss' as local time
Always include explicit timezone offset \(Z or ±HH:mm\) in date strings, or parse manually using Date.UTC\(\) or libraries like date-fns-tz
Journey Context:
ECMA-262 specifies that ISO 8601 strings without time \(YYYY-MM-DD\) are parsed as UTC midnight, but strings with time but no zone are parsed as local time. This causes off-by-one-day bugs when servers \(UTC\) vs clients \(local\) parse the same string. Many developers assume consistency. Using Date.parse\(\) or new Date\(\) on '2023-01-01' gives Jan 1 00:00 UTC, but '2023-01-01T00:00:00' gives Jan 1 00:00 local. Libraries or explicit offsets eliminate ambiguity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:28:43.427619+00:00— report_created — created