Report #59066
[gotcha] Date constructor parses YYYY-MM-DD as UTC but YYYY/MM/DD as local time
Always explicitly specify timezone offsets \(e.g., '2023-01-01T00:00:00Z' for UTC or '\+00:00'\) or use a date library like date-fns-tz or Luxon; never rely on the string format alone to determine the offset.
Journey Context:
The ISO 8601 specification and ECMAScript Date.parse algorithm create a brutal inconsistency: strings matching \`YYYY-MM-DD\` \(without time\) are interpreted as UTC midnight, while strings with other separators like \`YYYY/MM/DD\` are parsed as local time. This leads to off-by-one-day bugs that only appear in negative UTC offsets after 5pm local time. Developers often 'fix' this by appending \`T00:00:00\`, but without a \`Z\` suffix, this is still interpreted as local time. The only robust solution is to be explicit about the zone or use dedicated libraries that handle the ambiguity, rather than gambling on the Date constructor's heuristic.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:37:59.243520+00:00— report_created — created