Report #64415
[gotcha] Intl.DateTimeFormat validates timeZone at construction time, throwing on invalid zones
Always wrap Intl.DateTimeFormat construction in try-catch when using dynamic timeZone inputs. Validate timeZone strings against Intl.supportedValuesOf\('timeZone'\) if available, or use 'UTC' as a safe fallback.
Journey Context:
The Intl.DateTimeFormat constructor \(per ECMA-402\) attempts to get the 'timeZone' option and, if provided, validates it against the implementation's available time zone names. If the timeZone is invalid \(e.g., 'Mars/Phobos'\), it throws a RangeError immediately during construction, not during formatting. This creates a reliability issue when time zones come from user input or external APIs. Additionally, if timeZone is undefined, it defaults to the runtime's default time zone, which may differ between Node.js server and browser client, causing formatting mismatches. The fix requires defensive construction: either pre-validate against Intl.supportedValuesOf\('timeZone'\) \(ES2022\+\) or wrap the constructor in try-catch to fall back to 'UTC'. Note that the format\(\) method itself does not accept a timeZone override; it must be set at construction.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:36:39.610814+00:00— report_created — created