Report #6895
[gotcha] Date.parse interprets YYYY-MM-DD as UTC but YYYY-MM-DDTHH:mm as local time causing timezone shift bugs
Always append 'T00:00:00Z' to date-only strings to force UTC parsing, or use explicit timezone offsets. For local midnight, construct using new Date\(year, monthIndex, day\) instead of string parsing.
Journey Context:
Developers assume ISO 8601 strings behave consistently, but ECMAScript Date.parse follows a weird rule: date-only forms \(YYYY-MM-DD\) are parsed as UTC midnight, while datetime forms \(with T\) are parsed as local time. This causes off-by-one errors when displaying dates in negative timezones \(e.g., US timezones\) because UTC midnight becomes the previous day locally. The alternative of using slashes \(YYYY/MM/DD\) is implementation-defined and unreliable. The robust fix is avoiding string parsing for dates entirely and using constructor arguments or explicit Z suffix for UTC.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T01:17:06.090899+00:00— report_created — created