Time Zones and UTC in Dayjs

Store in UTC, display in local time and convert safely between regions with the UTC and Timezone plugins, including daylight saving edge cases.

Updated 15 November 20266 min readTime zones
Earth viewed from space with network lights, representing time zones in Dayjs

Time zones are where date handling becomes genuinely difficult. A meeting scheduled for 10:00 in London is 15:00 in Karachi and 05:00 in New York, and those relationships shift twice a year as different regions change their clocks on different dates. Get it wrong and customers miss appointments, reports count transactions on the wrong day and support teams spend hours untangling confusion. This guide explains how Dayjs approaches UTC and time zones, how to use the UTC and Timezone plugins, and which habits keep cross-region applications reliable.

Local time, UTC and named zones

By default, a Dayjs instance represents a moment expressed in the local time zone of the environment running the code: the visitor's device in a browser, or the server's configured zone in Node.js. That default is convenient for simple interfaces but risky for anything shared between people in different places.

Three concepts help clarify the picture:

  • An instant is a single point on the universal timeline, the same everywhere. A Unix timestamp describes an instant.
  • UTC is the global reference clock. It never observes daylight saving, so it is the safest way to store and exchange instants.
  • A named zone, such as Asia/Karachi or Europe/London, is a set of rules that maps instants to local clock times, including historical changes and daylight saving.

Most reliable systems follow a simple principle: store and transmit in UTC, convert to a named zone only when displaying a value to a person.

Working with UTC in Dayjs

The UTC plugin adds UTC mode to Dayjs. Load it once in your setup file, as described in our installation guide, and you gain several new capabilities.

import dayjs from 'dayjs'
import utc from 'dayjs/plugin/utc'
dayjs.extend(utc)

dayjs.utc()                         // current moment in UTC mode
dayjs.utc('2026-11-15 09:44')       // parse as UTC
dayjs('2026-11-15T14:44').utc()     // convert local to UTC
dayjs.utc('2026-11-15T09:44Z').local()  // convert back to local

An instance in UTC mode formats and manipulates according to the UTC clock. Calling .format('HH:mm') returns the UTC hour, and startOf('day') returns UTC midnight rather than local midnight. This is exactly what you want for server-side reporting, where a day should mean the same 24 hours regardless of where the code runs.

Reading and setting offsets

The plugin also provides utcOffset(), which returns the offset from UTC in minutes, or sets a fixed offset when given a number.

dayjs().utcOffset()          // e.g. 300 for UTC+05:00
dayjs.utc().utcOffset(120)   // fixed UTC+02:00 view

A fixed offset is not the same as a time zone. An offset of +01:00 describes London in summer but not in winter, whereas the zone Europe/London knows when to switch. For anything involving future dates or recurring events, use named zones.

Named time zones with the Timezone plugin

The Timezone plugin builds on UTC to support IANA zone names. It relies on the internationalisation features built into modern browsers and Node.js, so it adds very little to your bundle. Both plugins must be extended, and UTC must come first.

import timezone from 'dayjs/plugin/timezone'
dayjs.extend(utc)
dayjs.extend(timezone)

Converting an instant to another zone

Call .tz(zone) on an instance to view the same instant in another region.

const meeting = dayjs.utc('2026-11-15T10:00:00Z')

meeting.tz('Europe/London').format('HH:mm')    // '10:00'
meeting.tz('Asia/Karachi').format('HH:mm')     // '15:00'
meeting.tz('America/New_York').format('HH:mm') // '05:00'

Parsing a local time in a specific zone

Sometimes you know the wall-clock time in a place but not the instant, for example when a user in Karachi enters “15 November, 14:44”. Use dayjs.tz(value, zone) to interpret the string as local time in that region.

const local = dayjs.tz('2026-11-15 14:44', 'Asia/Karachi')
local.toISOString()   // '2026-11-15T09:44:00.000Z'

This distinction between converting an existing instant and interpreting a wall-clock time is the single most important concept in time zone handling. Confusing the two produces values that are off by exactly the zone offset, a bug that is easy to miss in testing if your own machine happens to sit in the same zone.

Guessing and defaulting the zone

The plugin can estimate the visitor's zone with dayjs.tz.guess(), which returns a name such as Asia/Karachi. You can also set a default zone for all subsequent dayjs.tz() calls.

const zone = dayjs.tz.guess()
dayjs.tz.setDefault('Europe/London')
dayjs.tz('2026-11-15 09:00')   // interpreted in London

Guessing is helpful for sensible defaults, but it should not replace an explicit preference. Let users confirm or change their zone in settings, and store that choice with their profile.

Daylight saving time and its traps

Daylight saving transitions create hours that occur twice and hours that never occur at all. When clocks move forward, a time such as 01:30 may simply not exist on that date in that zone. When they move back, 01:30 happens twice. The Timezone plugin resolves these cases according to the zone rules, but your business logic should still consider them.

Practical advice:

  • Schedule recurring events in a named zone, not a fixed offset, so that a daily 09:00 meeting stays at 09:00 local time after the clocks change.
  • Add calendar days, not 24 hours, when you mean “the same time tomorrow”. Our manipulation guide explains why.
  • Avoid scheduling automated jobs in the small hours of local time, when transitions occur; schedule them in UTC instead.
  • Test around transition dates for each region you serve, using fixed instants rather than the current time.

Server-side rendering and hydration

Frameworks that render on the server and then hydrate in the browser face a particular challenge. The server might run in UTC while the visitor sits in Karachi, so the same code produces different text on each side, triggering hydration warnings and flickering content.

Two strategies work well. The first is to render all timestamps in UTC, or in a zone stored with the user's account, on both server and client, so the output is identical. The second is to render a neutral placeholder on the server and format the local time only after the component mounts in the browser. Many teams use the first approach for primary content and the second for small details such as “last seen” labels.

Storing dates correctly

Good time zone handling begins with good storage. Save instants as ISO strings with a Z suffix, or as Unix timestamps, in UTC. Where the local context matters, as with a restaurant booking or a recurring class, also store the zone name alongside the instant, because offsets alone cannot be reconstructed into zones later.

// Saving
const payload = {
  startsAt: dayjs.tz('2026-11-20 19:00', 'Asia/Karachi').toISOString(),
  zone: 'Asia/Karachi'
}

// Displaying for another user
dayjs.utc(payload.startsAt).tz(viewerZone).format('ddd D MMM, HH:mm')

When values arrive from external systems without offsets, decide explicitly how to interpret them, using the parsing techniques in our parsing guide, and document that decision for future maintainers.

Displaying zone information to users

People trust times they can verify. When an interface shows times from several regions, label them clearly. Formatting with z or zzz, available once both the Timezone and AdvancedFormat plugins are loaded, prints an abbreviated or full zone name, while Z shows the numeric offset. Combining a local time with its zone label, such as “15:00 PKT”, removes doubt. For multilingual audiences, pair this with the locale techniques in our locales and internationalisation guide.

Testing time zone behaviour

Time zone bugs hide easily because developers often test in a single zone: their own. To expose problems early, run your test suite with the TZ environment variable set to several different values, such as UTC, Asia/Karachi and America/Los_Angeles. Tests that pass in all three are far more trustworthy than tests that pass on one laptop.

Use fixed instants in tests rather than the current time, and include dates either side of daylight saving transitions for the regions you serve. A test that converts a meeting scheduled for the week after the clocks change, and asserts the expected local time, protects one of the most common sources of customer complaints.

Performance considerations

The Timezone plugin uses the internationalisation features built into the JavaScript runtime. Conversion is fast enough for typical interfaces, but formatting thousands of values in different zones inside a tight loop can become noticeable. In such cases, convert once and reuse the result, or perform heavy reporting on the server where results can be cached.

Older environments with limited internationalisation support may lack full zone data. Modern browsers and current Node.js releases include it by default, but if you target unusual platforms, verify support early in the project rather than discovering gaps in production.

Conclusion

Time zones become manageable once you separate three ideas: instants, the UTC reference clock and named zones with their changing rules. In Dayjs, the UTC plugin gives you a stable reference for storage and reporting, while the Timezone plugin converts instants to any IANA zone and interprets wall-clock times correctly. Store in UTC, keep zone names alongside events that depend on local context, schedule recurring items in named zones and test around daylight saving transitions. With those habits in place, your application will present the right time to every user, wherever they happen to be.