Report #30979
[gotcha] Date parsing treats date-only strings as UTC but datetime strings as local time
Always append explicit timezone offset \(Z or \+/-HH:MM\) to date strings before parsing. Use date-fns-tz or Luxon for timezone-aware parsing instead of native Date constructor.
Journey Context:
Per ECMAScript Date.parse specification, date-only strings \(YYYY-MM-DD\) are interpreted as UTC midnight, while strings with time components \(YYYY-MM-DDTHH:mm:ss\) without timezone offsets are interpreted as local time. This creates subtle bugs where adding a time component shifts the date by the timezone offset \(e.g., new Date\('2023-01-01'\) vs new Date\('2023-01-01T00:00:00'\) give different results in negative timezones\). The spec tries to align with ISO 8601 but introduces this inconsistency. Solutions include always using UTC methods, parsing with libraries that handle timezones explicitly \(Luxon, date-fns-tz\), or manually normalizing strings to include Z for UTC.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T06:23:14.909929+00:00— report_created — created