# Time Zones

> The Time Zones are regions that share the same standard time, defined by an offset from UTC and daylight saving rules.

## How should I handle time zones in web apps?

The regions with the same local time, identified by names like 'Europe/Berlin'. Offsets change with daylight saving time, so dates are stored in UTC and converted to the user's time zone only for display.

- Topic: Internationalization
- Type: concept

## Example

Wrong:

```js
const berlinOffset = 2; // hours
const local = new Date(utc.getTime() + berlinOffset * 3600000);
```

Right:

```js
const format = new Intl.DateTimeFormat('de-DE', {
  timeZone: 'Europe/Berlin',
  dateStyle: 'medium',
  timeStyle: 'short',
});
const local = format.format(utc);
```

A fixed offset breaks after daylight saving changes; a named time zone lets `Intl` apply the right offset for each date.

## Common mistakes

- Storing local time without a time zone, which shifts events after daylight saving changes.

## Key points

- Dates are stored and sent in UTC, usually as ISO strings.
- Display uses `Intl.DateTimeFormat` with the user's `timeZone`, not manual offset math.

## Interview questions

### How do I get the user's time zone in JavaScript?

Call `Intl.DateTimeFormat().resolvedOptions().timeZone`, which returns an IANA name like 'Europe/Berlin'.

### Should I store a time zone name or a UTC offset?

Store the IANA name for future local events. Offsets change with daylight saving and law changes, names keep the rules.

### What is the difference between UTC and GMT?

For apps they show the same time. UTC is the precise time standard, GMT is a time zone name used in the UK in winter.

## Related cards

- [Intl.DateTimeFormat](https://wonderium.dev/js/intl-datetime-format.md)
- [.toISOString()](https://wonderium.dev/js/date-to-iso-string.md)
- [Date](https://wonderium.dev/js/date.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/time-zones
- Last updated: 2026-11-25
