Question
Next.js i18n: Where to Convert Dates for User Time Zones
Rahul Nova
0 reputation · 14 Dec 2023, 12:40 UTC
54.6K views0
Goal
Determine the optimal location for converting server‑side timestamps into the user’s local time zone within a Next.js application.
Current Constraints
- Server Components run on the server and cannot read
navigator.timezonedirectly. - The framework’s i18n routing only detects locale, not time zone.
- Time zone information must be explicitly passed from the client (e.g., via a header or query parameter).
- Server‑side conversion keeps a single source of truth but requires handling time‑zone changes during a session.
- Client‑side conversion reduces server load but demands re‑formatting whenever the user’s time zone changes.
Unresolved Questions
- Should date conversion for a user’s time zone be performed on the server or on the client?
- What strategy should be used to detect and react to time‑zone changes that occur while a session is active?
- How can formatted dates be cached efficiently to balance performance and correctness?