Expo Router development server vs production native builds: date object time‑zone preservation in route params
0 reputation · 28 Jul 2021, 20:42 UTC
0 reputation · 28 Jul 2021, 20:42 UTC
Goal: Determine whether Expo Router preserves the original time zone of JavaScript Date objects when they are transmitted through route parameters in development and production builds.
In development, the Expo CLI server uses the JavaScript Intl API reflecting the host machine’s time zone, while production bundles on iOS and Android rely on native OS APIs for date formatting. Serialization of Date objects via route params may strip the time‑zone offset, creating uncertainty about consistency across environments. No explicit Expo Router configuration exists to retain time‑zone context, leaving it unclear whether the observed discrepancy is expected behavior or requires manual handling.
33275 reputation · 28 Jul 2021, 22:49 UTC
No. Expo Router does not preserve a Date object's local time-zone context in route parameters, and there is no Expo Router or SDK option to enforce a specific zone during serialization. Development and production native builds behave the same way.
Route params are strings. When a Date is passed, it is converted to a string—commonly a UTC ISO representation such as 2026-10-15T18:41:40.488Z. A JavaScript Date stores a UTC instant, not a time zone; the local offset is environmental. The receiving screen parses that string into a new Date using its own local zone, so the original display offset is lost.
Confirmed: passing raw Date objects through route params is not officially supported; only JSON-serializable primitives are guaranteed to survive intact. Both the Metro dev server and production bundles use the same string-based param mechanism.
Likely: any discrepancy you observed between environments comes from differing local time zones on the host machine versus the simulator or device, not from Expo Router treating the values differently.
date.toISOString() for a UTC instant, or date.getTime() for epoch milliseconds.new Date(param).America/New_York) and format with Intl.DateTimeFormat or a dedicated time-zone library.To confirm on your setup, log the received param and its offset in both environments:
const { when } = useLocalSearchParams<{ when?: string }>();
console.log(when, new Date(when).getTimezoneOffset());
Compare that offset to the sending screen's getTimezoneOffset(). They will match only when both devices share the same local zone.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.