Report #26307
[gotcha] Why does new Date\('2023-01-01'\) give a different day than new Date\('2023-01-01T00:00:00'\)?
Always include explicit timezone offsets in Date strings. Use ISO 8601 format with 'Z' for UTC \(e.g., '2023-01-01T00:00:00Z'\). Never rely on date-only strings for local time calculations, as they are parsed as UTC while datetime strings without 'Z' are parsed as local time.
Journey Context:
ECMAScript specifies that date-only strings \(YYYY-MM-DD\) are interpreted as UTC midnight, while datetime strings \(YYYY-MM-DDTHH:mm:ss\) without timezone are interpreted as local time. This causes '2023-01-01' to become Jan 1 UTC \(which might be Dec 31 locally\), while '2023-01-01T00:00:00' becomes midnight local time. Developers often assume both are local or both are UTC. The safest pattern is to always append 'Z' for UTC or explicit offsets \(\+05:00\) and convert to local display only at the UI layer.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T22:33:24.144969+00:00— report_created — created