Report #10149
[gotcha] Date constructor parses date-only strings as UTC but datetime strings as local time
Always use ISO 8601 strings with explicit time components \(T00:00:00\) and timezone offsets \(Z or \+/-HH:MM\), or migrate to the Temporal API instead of legacy Date.
Journey Context:
The ECMA-262 spec mandates that date-only strings \(YYYY-MM-DD\) are parsed as UTC midnight, while strings with time components are parsed as local time. This causes off-by-one-day bugs when the local timezone is behind UTC \(e.g., Americas\). Developers often assume consistent parsing or believe Date.parse normalizes everything. Libraries like date-fns wrap this safely, but the only spec-compliant fix is explicit time\+offset notation or using Temporal.PlainDate which lacks time components entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:54:13.237574+00:00— report_created — created