Report #104295
[gotcha] new Date\('2024-01-01'\) returns a date in UTC, while new Date\('2024/01/01'\) returns a date in local timezone, causing unexpected date shifts
Always use ISO 8601 strings with timezone offset \(e.g., '2024-01-01T00:00:00Z'\) or use a library like date-fns/parse to be explicit. Avoid non-standard date strings.
Journey Context:
The ECMAScript spec says that date-only strings in ISO 8601 format \(YYYY-MM-DD\) are parsed as UTC. Other formats \(like YYYY/MM/DD\) are parsed as local time. This inconsistency is a common source of bugs, especially in applications that display dates across timezones. The fix is to always specify a timezone or use a parser that forces a timezone. The tradeoff is verbosity, but it prevents subtle bugs. Many developers assume '2024-01-01' is local, but it's not.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-26T20:05:41.385542+00:00— report_created — created