If you have worked with dates in JavaScript, you have probably been caught out by Date. Months start at zero. Objects are mutable, so passing a date into a function can change it behind your back. Parsing strings behaves differently depending on the format. There is no proper time zone support beyond the user's local zone and UTC. Adding a month or working out the number of days between two dates means writing your own maths, or installing a library like date-fns, Luxon or Day.js.

Temporal is the replacement. It is a new global object, built into the language, with separate types for the different things people mean when they say "a date": a calendar date, a wall-clock time, an exact moment, or a length of time. It reached Stage 4 at TC39 in March 2026, which means it is part of the ECMAScript standard.

This article is for JavaScript developers who want to understand Temporal's main types, when to use each one, and how to adopt it today, including in browsers that do not have it yet.

The core idea: pick the right type

#

Date tries to be everything at once. Under the hood it is just a count of milliseconds since 1 January 1970 UTC, and every method converts that number to your local time zone on the fly. That is why a birthday stored as a Date can show up as the day before for someone in another country.

Temporal splits this into types that each carry exactly the information they need:

TypeWhat it representsExample
Temporal.PlainDateA calendar date, no time or zoneA birthday, a public holiday
Temporal.PlainTimeA wall-clock time, no date or zoneOpening time: 09:00
Temporal.PlainDateTimeA date and time, no zoneA local event time before you know the zone
Temporal.ZonedDateTimeA date and time in a specific time zoneA meeting at 10:00 in London
Temporal.InstantAn exact moment on the global timelineA log timestamp
Temporal.DurationA length of time1 hour 30 minutes

There are also Temporal.PlainYearMonth and Temporal.PlainMonthDay for things like "November 2026" or "25 December", and Temporal.Now for getting the current time.

Two rules apply to every type:

  • They are immutable. Methods like add() return a new object instead of changing the original.
  • Months are numbered from 1. January is 1, December is 12.

PlainDate: calendar dates without time zone bugs

#

Use PlainDate whenever the time of day does not matter.


_10
const birthday = Temporal.PlainDate.from('1990-06-15');
_10
_10
birthday.year; // 1990
_10
birthday.month; // 6
_10
birthday.day; // 15
_10
birthday.dayOfWeek; // 5 (Monday is 1, Sunday is 7)
_10
_10
const today = Temporal.Now.plainDateISO();

You can also build one from parts:


_10
const launch = Temporal.PlainDate.from({ year: 2026, month: 11, day: 27 });
_10
launch.toString(); // '2026-11-27'

Doing arithmetic

Adding days, weeks, months or years is built in:


_10
const start = Temporal.PlainDate.from('2026-01-31');
_10
_10
start.add({ days: 1 }).toString(); // '2026-02-01'
_10
start.add({ months: 1 }).toString(); // '2026-02-28'
_10
start.subtract({ years: 1 }).toString(); // '2025-01-31'

Notice that adding one month to 31 January gives 28 February, not 3 March. By default Temporal constrains the result to the last valid day of the month. If you would rather get an error, pass { overflow: 'reject' } as a second argument.

To change one field, use with():


_10
const firstOfMonth = start.with({ day: 1 }); // 2026-01-01

Working out the difference

until() and since() return a Duration:


_10
const today = Temporal.PlainDate.from('2026-11-27');
_10
const christmas = Temporal.PlainDate.from('2026-12-25');
_10
_10
today.until(christmas).days; // 28
_10
_10
const age = Temporal.PlainDate.from('1990-06-15')
_10
.until(today, { largestUnit: 'year' });
_10
_10
age.years; // 36

The largestUnit option controls how the result is broken down. Without it, PlainDate differences are expressed in days.

ZonedDateTime: real-world times in real time zones

#

ZonedDateTime is the type to reach for when you are dealing with something that happens at a particular time in a particular place. It knows its IANA time zone, such as Europe/London or America/New_York, and it handles daylight saving time for you.


_10
const meeting = Temporal.ZonedDateTime.from(
_10
'2026-11-30T10:00[Europe/London]'
_10
);
_10
_10
meeting.toString();
_10
// '2026-11-30T10:00:00+00:00[Europe/London]'

Converting to another zone is one method call:


_10
const inNewYork = meeting.withTimeZone('America/New_York');
_10
inNewYork.hour; // 5

To get the current time in the user's zone:


_10
const now = Temporal.Now.zonedDateTimeISO();
_10
now.timeZoneId; // for example 'Europe/London'

Daylight saving time, handled

In the UK, clocks go forward at 01:00 on 29 March 2026. That day is only 23 hours long. Watch what happens when you add a day compared with adding 24 hours:


_10
const before = Temporal.ZonedDateTime.from(
_10
'2026-03-28T12:00[Europe/London]'
_10
);
_10
_10
before.add({ days: 1 }).toString();
_10
// '2026-03-29T12:00:00+01:00[Europe/London]'
_10
_10
before.add({ hours: 24 }).toString();
_10
// '2026-03-29T13:00:00+01:00[Europe/London]'

Adding a day keeps the same wall-clock time, which is what you want for "same time tomorrow". Adding 24 hours adds exactly 24 real hours. With Date, you would have to know about this and handle it yourself.

Instant: exact moments for machines

#

Instant is a point on the global timeline with no time zone or calendar attached. It is the closest thing in Temporal to what Date actually stores, but with nanosecond precision.

Use it for timestamps: logs, database records, API responses, measuring when something happened.


_10
const now = Temporal.Now.instant();
_10
now.toString(); // '2026-11-27T14:03:12.123456789Z'
_10
_10
const created = Temporal.Instant.from('2026-11-27T09:00:00Z');
_10
now.since(created).toString(); // for example 'PT18192.123456789S'

When you need to show an instant to a person, convert it to a zoned value first:


_10
const local = created.toZonedDateTimeISO('Europe/London');
_10
local.toLocaleString('en-GB', { dateStyle: 'full', timeStyle: 'short' });
_10
// 'Friday 27 November 2026 at 09:00'

A good rule: store and send Instant values (as ISO strings with a Z), and convert to ZonedDateTime at the edge, when displaying to a user.

Duration: lengths of time

#

Duration represents an amount of time, such as "2 hours 30 minutes" or "1 year 2 months". You get one from until() and since(), or create one directly:


_10
const film = Temporal.Duration.from({ hours: 2, minutes: 15 });
_10
_10
film.toString(); // 'PT2H15M'
_10
film.total({ unit: 'minutes' }); // 135
_10
_10
const longer = film.add({ minutes: 50 });
_10
longer.round({ largestUnit: 'hour' }).toString(); // 'PT3H5M'

Durations also format nicely for display with toLocaleString(), in environments that support Intl.DurationFormat:


_10
film.toLocaleString('en-GB', { style: 'long' });
_10
// '2 hours, 15 minutes'

One subtlety: durations containing years, months or weeks do not have a fixed length. A month might be 28 or 31 days. Methods that need to know the real length, such as total() or Duration.compare() on calendar units, require a relativeTo option telling Temporal which date to measure from:


_10
const oneMonth = Temporal.Duration.from({ months: 1 });
_10
_10
oneMonth.total({
_10
unit: 'days',
_10
relativeTo: Temporal.PlainDate.from('2026-02-01'),
_10
}); // 28

Comparing values

#

This is a place where Temporal deliberately differs from Date. With Date, you can write a < b because the object quietly converts to a number. Temporal objects throw a TypeError if you try that, to stop you from accidentally comparing values that do not mean the same thing.

Use equals() for equality and the static compare() for ordering:


_10
const a = Temporal.PlainDate.from('2026-11-27');
_10
const b = Temporal.PlainDate.from('2026-12-25');
_10
_10
a.equals(b); // false
_10
Temporal.PlainDate.compare(a, b); // -1
_10
_10
const dates = [b, a];
_10
dates.sort(Temporal.PlainDate.compare); // [a, b]

compare() returns -1, 0 or 1, which is exactly the shape Array.prototype.sort() wants.

Temporal compared with Date

#

Here are some common tasks side by side.

Getting tomorrow's date:


_10
// Date
_10
const d = new Date();
_10
d.setDate(d.getDate() + 1); // mutates d
_10
_10
// Temporal
_10
const tomorrow = Temporal.Now.plainDateISO().add({ days: 1 });

Creating 1 March 2026:


_10
// Date: month index 2 means March
_10
new Date(2026, 2, 1);
_10
_10
// Temporal: month 3 means March
_10
Temporal.PlainDate.from({ year: 2026, month: 3, day: 1 });

Showing a time in another zone:


_10
// Date: only possible through formatting
_10
new Date().toLocaleString('en-GB', { timeZone: 'Asia/Tokyo' });
_10
_10
// Temporal: a real value you can keep working with
_10
Temporal.Now.zonedDateTimeISO('Asia/Tokyo').add({ hours: 2 });

Moving between the two

You will be working alongside Date for a long time, especially with older libraries. Conversion is straightforward through Instant:


_10
// Date to Temporal
_10
const legacy = new Date();
_10
const instant = legacy.toTemporalInstant();
_10
// or: Temporal.Instant.fromEpochMilliseconds(legacy.getTime())
_10
_10
// Temporal to Date
_10
const back = new Date(instant.epochMilliseconds);

Serialising to JSON

Temporal objects turn into ISO 8601 strings with JSON.stringify(). When reading JSON back, you get strings, so parse them with the matching from() method:


_10
const payload = JSON.stringify({ due: Temporal.PlainDate.from('2026-12-01') });
_10
// '{"due":"2026-12-01"}'
_10
_10
const { due } = JSON.parse(payload);
_10
const dueDate = Temporal.PlainDate.from(due);

Using Temporal in TypeScript

#

Recent versions of TypeScript include type definitions for Temporal under the newer lib options. If your setup does not recognise the global yet, the polyfill packages below ship their own types, and you can import Temporal from them directly.

Version support

#

At the time of writing (late 2026):

  • Firefox has shipped Temporal since version 139, released in 2025.
  • Chrome and Edge shipped it in version 144, in January 2026.
  • Node.js includes it from Node.js 26.
  • Safari does not support it in a stable release yet. Work is under way in WebKit, but you should not assume it is there.

Because Safari is the default on every iPhone, you cannot use the global Temporal unguarded on a public website yet. There are two well-maintained polyfills:

  • @js-temporal/polyfill, from the champions of the proposal.
  • temporal-polyfill, a smaller alternative.

You can import from a polyfill directly, which works everywhere:


_10
npm install @js-temporal/polyfill


_10
import { Temporal } from '@js-temporal/polyfill';
_10
_10
const today = Temporal.Now.plainDateISO();

Or use the native object when it exists and load the polyfill only when it does not:


_10
async function getTemporal() {
_10
if (globalThis.Temporal) return globalThis.Temporal;
_10
const { Temporal } = await import('@js-temporal/polyfill');
_10
return Temporal;
_10
}

Polyfills add weight to your bundle, so check the current size before you add one, and plan to remove it once your supported browsers all ship Temporal natively. Check caniuse for the latest support data.

When not to use it

#
  • Simple timestamps in performance code. For measuring how long something took, performance.now() is lighter and more precise for that job.
  • When a polyfill is too heavy. On a small page that only formats one date, Intl.DateTimeFormat with a plain Date may be enough, and avoids shipping a polyfill to Safari users.
  • Mixing types carelessly. Temporal will not let you add a PlainDate to a ZonedDateTime without being explicit. If your code needs lots of conversions, step back and decide which type the data should really be.
  • Libraries that expect Date. Many date pickers, ORMs and charting libraries still take Date objects. Convert at the boundary rather than fighting them.

Wrapping up

#
  • Choose the type that matches your data: PlainDate for calendar dates, ZonedDateTime for real-world times in a place, Instant for exact timestamps and Duration for lengths of time.
  • Temporal objects are immutable and months start at 1, removing two of the biggest sources of Date bugs.
  • Compare values with equals() and compare(), never with the less-than or greater-than operators.
  • Time zone and daylight saving maths are built in, so adding a day and adding 24 hours now mean different, correct things.
  • Firefox, Chrome, Edge and Node.js have Temporal natively; use a polyfill for Safari until it ships there.
#
file under:
Javascript

Was this article helpful?

About the author

Danny Engineering

A software engineer with a strong belief in human-centric design and driven by a deep empathy for users. Combining the latest technology with human values to build a better, more connected world.