Skip to content
CompanyBenchCompanyBench

Handling time zones in global products

Store timestamps in UTC, localise on the client, test daylight saving edge cases and use proven libraries. Practical time zone rules for global products.

Users expect calendars, logs and transactions to behave the same way wherever they are. When time zone logic is wrong, you get bugs, missed meetings and compliance problems, and users stop trusting the product. The fix is not clever code. It is a small set of conventions applied consistently, from storage to display.

Time is not absolute. Good time zone engineering is about removing ambiguity so every user sees consistent behaviour.

Store everything in UTC

Keep every timestamp in UTC on the backend and let the client convert it to the user's preferred zone. That gives you one source of truth. Don't store local times in the database: they become ambiguous during daylight saving changes or when a user moves. If you need the user's zone, record it in a separate field.

Storing local times is like hardcoding assumptions into your schema. It works until it doesn't.

Show time in the user's context

Localise on display

Show users times in their own zone, and don't mix server time with local time or switch formats between screens. Libraries such as `date-fns-tz` or the built-in `Intl.DateTimeFormat` handle the conversion reliably.

Label the zone explicitly

When you schedule or display a future time, show the zone (for example GMT+2). It prevents surprises when an event or reminder fires.

Plan for daylight saving and rule changes

Time zone rules change for legal and political reasons. Use current IANA time zone data, and keep it updated, through your CI/CD pipeline if that helps. Test the transitions where an hour disappears or repeats, since that is where most scheduling bugs hide.

Build time logic that scales

Use established libraries

Don't write your own date arithmetic. Use well-tested libraries such as Luxon, Moment-Timezone or `ZonedDateTime` in Java.

Model time ranges clearly

For bookings and event windows, store explicit start and end times in UTC. Document the rules so downstream systems interpret them the same way.

Decide what happens when users travel

A user's zone changes when they travel. Decide whether their scheduled actions stay in the original zone or follow them, and tell users which behaviour to expect.

Make it a team convention

Time handling touches every layer, from frontend rendering to analytics pipelines. Agree on conventions across engineering, provide shared utility functions, look for time edge cases in code review, and write docs that new developers can follow. Like security, getting time right is everyone's job, not only the backend team's.