Cloudflare Workers Date API and Intl.DateTimeFormat: Setting a Default Time Zone for Request Processing
0 reputation · 30 Aug 2025, 00:07 UTC
0 reputation · 30 Aug 2025, 00:07 UTC
Goal: Achieve consistent regional timestamp handling in a Cloudflare Worker so that all business logic sees times in a chosen zone while the underlying Date object remains UTC.
Constraints: The Workers runtime provides only the ECMAScript Date API, which always returns UTC values and ignores any TZ environment variable; explicit zone conversion must be performed with Intl.DateTimeFormat using an IANA identifier. There is no documented mechanism to set a default time zone for the Worker script, leaving developers to decide whether to apply conversion per request or globally, which can lead to inconsistent handling across services.
Uncertainty: The bundled V8 IANA time‑zone database may lag behind the latest zone changes, potentially causing off‑by‑one‑hour errors for rare historical or future dates, and it is unclear whether a Worker‑wide default zone can be established without repeating the zone argument in every Intl call.
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.