Report #96830
[gotcha] Date constructor parses ISO date-only strings as UTC but ISO datetimes as local time
Always include explicit timezone offset \(Z or ±HH:mm\) in ISO strings, or use the UTC methods \(\`Date.UTC\`, \`setUTCFullYear\`\) when constructing dates. For parsing ambiguous strings, use a robust library like \`date-fns-tz\` or \`luxon\` instead of native Date parsing.
Journey Context:
The ECMAScript Date constructor applies different timezone rules based on whether the ISO string contains a time component. \`YYYY-MM-DD\` is parsed as UTC midnight, while \`YYYY-MM-DDTHH:mm:ss\` \(without Z\) is parsed as local time. This leads to off-by-one errors in date pickers where the date shifts based on the local timezone offset from UTC. Developers assume consistent parsing rules, but the spec treats date-only as UTC to align with ISO 8601 calendar dates, whereas full datetimes without timezone are local per common practice.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:06:49.055166+00:00— report_created — created