Report #30633
[gotcha] Date constructor parses ISO 8601 date-only strings as UTC but date-time strings as local time
Always use full ISO 8601 datetime strings with explicit timezone offsets \(e.g., '2023-01-01T00:00:00Z' or '\+00:00'\) when parsing dates, or use a dedicated date library \(date-fns, luxon\) for parsing.
Journey Context:
Developers assume \`new Date\('2023-01-01'\)\` creates Jan 1st midnight local time. However, per ECMAScript Date Time String Format \(20.4.3.2\), date-only forms are parsed as UTC, yielding a time value equivalent to UTC midnight. When displayed via \`toLocaleDateString\(\)\`, this appears as Dec 31st for users west of GMT. Conversely, \`new Date\('2023-01-01T00:00:00'\)\` \(with time but no zone\) is parsed as local time. This bifurcation is a legacy spec compromise. The robust pattern is explicit offsets or using libraries that decouple parsing from display.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:48:11.697507+00:00— report_created — created