Skip to main content

JavaScript Temporal API: The Complete Guide to Dates, Times, and Time Zones

Learn the Temporal API, JavaScript's modern replacement for Date. Covers Instant, ZonedDateTime, PlainDate, Duration, time zone and DST handling, date arithmetic, formatting, serialization, migrating from Date, and polyfills with practical examples.

Table of Contents

Introduction

JavaScript’s Date object was copied from Java in 1995, in about ten days. Java deprecated most of its version two years later. JavaScript kept its version for nearly three decades, and an entire ecosystem of libraries (Moment.js, date-fns, Luxon, Day.js) grew up around it to paper over the gaps.

Temporal is the replacement. It’s a new global namespace with a set of immutable types that separate concepts Date lumps together: an exact moment, a calendar date, a wall-clock time, a time zone, and a length of time. It handles time zones and daylight saving time correctly, does calendar-aware arithmetic, and parses only well-defined formats.

After years as a Stage 3 proposal, Temporal now ships natively in Firefox and Chromium-based browsers, with polyfills covering everything else. That makes this a good time to learn it properly.

This guide covers:

  • Why Date is so error-prone, and how Temporal’s types fix it
  • Which type to use for which job
  • Time zones, DST, and the disambiguation option
  • Date arithmetic, durations, comparisons, and rounding
  • Formatting, serialization, and database storage
  • Migrating an existing codebase from Date and date libraries

What’s Wrong with Date

Before looking at Temporal, it helps to be precise about what it replaces. Date has problems at every level.

It’s Mutable

const start = new Date("2026-10-27");
const end = start;
end.setDate(end.getDate() + 7);
console.log(start.toISOString()); // 2026-11-03... start changed too!

Any function that receives a Date can modify it. Defensive copying (new Date(date)) is the only protection.

Months Are Zero-Indexed (Days Aren’t)

new Date(2026, 1, 1); // February 1st, not January 1st
new Date(2026, 12, 1); // Silently rolls over to January 1st, 2027

It Only Knows Two Time Zones

A Date is a timestamp. It can show that timestamp in UTC or in the user’s local time zone, and nothing else. There’s no way to ask “what time is it in Tokyo?” without converting to a string through Intl.

Parsing Is Inconsistent

new Date("2026-10-27"); // Midnight UTC
new Date("2026-10-27T00:00"); // Midnight local time
new Date("10/27/2026"); // Implementation-defined format
new Date("2026-02-31"); // Invalid Date in some engines, March 3rd in others historically

A date-only ISO string is parsed as UTC, but a date-time string without an offset is parsed as local time. This one rule has caused countless “off by one day” bugs for users west of Greenwich.

It Conflates Different Concepts

A birthday, a meeting, a log timestamp, and a store’s opening hours are all different kinds of data:

DataWhat it really is
BirthdayA calendar date, no time, no time zone
Store opens at 9:00A wall-clock time, no date
Server log entryAn exact moment, time zone irrelevant
Meeting in BerlinA date, time, and a specific time zone
Credit card expiry 10/28A year and month only

Date represents all of them as “milliseconds since 1970 in UTC”, so you’re constantly converting and hoping nothing shifts. Store a birthday as new Date("1990-05-14"), display it in California, and it becomes May 13th.


The Temporal Type System

Temporal gives each of those concepts its own type. Every type is immutable: methods return new objects instead of changing the original.

Exact time (a moment on the timeline)
┌────────────────────────────────────┐
│ Temporal.Instant │
│ Temporal.ZonedDateTime ◄── also has a time zone
└────────────────────────────────────┘
Wall-clock time (no time zone)
┌────────────────────────────────────┐
│ Temporal.PlainDateTime │
│ Temporal.PlainDate │
│ Temporal.PlainTime │
│ Temporal.PlainYearMonth │
│ Temporal.PlainMonthDay │
└────────────────────────────────────┘
Length of time
┌────────────────────────────────────┐
│ Temporal.Duration │
└────────────────────────────────────┘
TypeExampleUse for
Instant2026-10-27T09:30:00ZLog timestamps, createdAt, events
ZonedDateTime2026-10-27T10:30:00+01:00[Europe/Berlin]Meetings, flights, anything scheduled
PlainDate2026-10-27Birthdays, holidays, due dates
PlainTime09:00:00Opening hours, alarms
PlainDateTime2026-10-27T09:00:00Form input before a zone is known
PlainYearMonth2026-10Card expiry, monthly reports
PlainMonthDay10-27Recurring anniversaries
DurationPT1H30MTimers, video length, SLA windows

The key mental split is exact time versus wall-clock time. An Instant is the same moment for everyone on Earth. A PlainDateTime of “2026-10-27 09:00” is a different moment in every time zone, so Temporal won’t let you treat it as a moment until you supply one.

There are no TimeZone or Calendar classes. Time zones are plain IANA identifier strings like "Europe/Berlin", and calendars are strings like "iso8601" or "hebrew".


Getting the Current Time

Temporal.Now replaces Date.now() and new Date():

Temporal.Now.instant(); // Exact current moment
Temporal.Now.timeZoneId(); // "Europe/Berlin" (the system time zone)
Temporal.Now.zonedDateTimeISO(); // Now, in the system time zone
Temporal.Now.zonedDateTimeISO("Asia/Tokyo"); // Now, in Tokyo
Temporal.Now.plainDateISO(); // Today's date in the system time zone
Temporal.Now.plainDateISO("America/New_York"); // Today's date in New York
Temporal.Now.plainTimeISO(); // Current wall-clock time

The ISO suffix means “use the ISO 8601 calendar”, which is the Gregorian calendar you almost certainly want.

Note that “today” depends on where you are. At 23:00 in New York, it’s already tomorrow in Berlin. Temporal.Now.plainDateISO() makes you think about that, whereas new Date() hides it.


Creating and Parsing Values

Every type has a static from() method that accepts either an ISO 8601 string or a property bag:

// From strings
const date = Temporal.PlainDate.from("2026-10-27");
const time = Temporal.PlainTime.from("14:30");
const instant = Temporal.Instant.from("2026-10-27T13:30:00Z");
const meeting = Temporal.ZonedDateTime.from(
"2026-10-27T14:30:00[Europe/Berlin]",
);
// From property bags. Months are 1-indexed!
const date2 = Temporal.PlainDate.from({ year: 2026, month: 10, day: 27 });
const meeting2 = Temporal.ZonedDateTime.from({
timeZone: "America/New_York",
year: 2026,
month: 12,
day: 1,
hour: 9,
});

Strict Parsing

Temporal only accepts well-defined formats. There’s no guessing:

Temporal.PlainDate.from("10/27/2026"); // RangeError
Temporal.Instant.from("2026-10-27T09:00:00"); // RangeError: no offset, not an exact time

The second error is a feature. A string without a Z or offset doesn’t identify a moment, so it can’t become an Instant.

Handling Invalid Values with overflow

What happens with February 31st? You choose, using the overflow option:

Temporal.PlainDate.from({ year: 2026, month: 2, day: 31 });
// 2026-02-28 (default: "constrain" clamps to the nearest valid value)
Temporal.PlainDate.from(
{ year: 2026, month: 2, day: 31 },
{ overflow: "reject" },
);
// RangeError

Use "reject" when validating user input. A form that accepts “February 31st” and silently saves February 28th is a bug.

Note that ISO strings are always strict: Temporal.PlainDate.from("2026-02-31") throws regardless of the option.

Modifying with with()

Since values are immutable, you derive new ones with with():

const date = Temporal.PlainDate.from("2026-10-27");
date.with({ day: 1 }); // 2026-10-01 (first of the month)
date.with({ month: 12, day: 25 }); // 2026-12-25
date.with({ day: date.daysInMonth }); // 2026-10-31 (last of the month)
console.log(date.toString()); // 2026-10-27, unchanged

Plain Types: Dates Without Time Zones

Plain types are for values that don’t refer to a specific moment. They’re the right default for most calendar data in a UI.

PlainDate

const date = Temporal.PlainDate.from("2026-10-27");
date.year; // 2026
date.month; // 10
date.day; // 27
date.dayOfWeek; // 2 (Monday = 1, Sunday = 7)
date.dayOfYear; // 300
date.weekOfYear; // 44
date.daysInMonth; // 31
date.inLeapYear; // false
date.monthCode; // "M10"

A birthday stored as a PlainDate is May 14th everywhere in the world. It never shifts when someone views it from another continent.

PlainTime

const opens = Temporal.PlainTime.from("09:00");
const closes = Temporal.PlainTime.from("17:30");
const now = Temporal.Now.plainTimeISO();
const isOpen =
Temporal.PlainTime.compare(now, opens) >= 0 &&
Temporal.PlainTime.compare(now, closes) < 0;

PlainDateTime

A PlainDateTime is what an <input type="datetime-local"> gives you: a date and time with no zone. Treat it as an intermediate value and convert it to a ZonedDateTime once you know the zone:

const input = document.querySelector('input[type="datetime-local"]');
const local = Temporal.PlainDateTime.from(input.value); // "2026-11-05T15:00"
const scheduled = local.toZonedDateTime("Europe/Berlin");

PlainYearMonth and PlainMonthDay

// Credit card expiry
const expiry = Temporal.PlainYearMonth.from("2028-10");
const thisMonth = Temporal.Now.plainDateISO().toPlainYearMonth();
const expired = Temporal.PlainYearMonth.compare(expiry, thisMonth) < 0;
// Recurring anniversary: what date is it this year?
const anniversary = Temporal.PlainMonthDay.from("02-29");
anniversary.toPlainDate({ year: 2027 }); // 2027-02-28 (constrained)
anniversary.toPlainDate({ year: 2028 }); // 2028-02-29

Combining Plain Types

const date = Temporal.PlainDate.from("2026-12-24");
const time = Temporal.PlainTime.from("18:00");
date.toPlainDateTime(time); // 2026-12-24T18:00:00
date.toZonedDateTime({ timeZone: "Europe/Vienna", plainTime: time });
date.toZonedDateTime("Europe/Vienna"); // Start of that day in Vienna

Instant: Exact Points in Time

An Instant is a point on the global timeline with nanosecond precision. It has no time zone, no calendar, and no concept of “days” or “months”. It’s the Temporal equivalent of a Unix timestamp, and the closest thing to what Date actually is.

const instant = Temporal.Now.instant();
instant.epochMilliseconds; // 1793093400000
instant.epochNanoseconds; // 1793093400000000000n (a BigInt)
instant.toString(); // "2026-10-27T09:30:00.123456789Z"
Temporal.Instant.fromEpochMilliseconds(1793093400000);

Use Instant for anything that records when something happened: createdAt, audit logs, analytics events, cache expiry. These values never need a time zone until you show them to a human.

To display an Instant, project it into a time zone:

const event = Temporal.Instant.from("2026-10-27T09:30:00Z");
event.toZonedDateTimeISO("Europe/Berlin").toString();
// "2026-10-27T10:30:00+01:00[Europe/Berlin]"
event.toZonedDateTimeISO("Asia/Tokyo").toString();
// "2026-10-27T18:30:00+09:00[Asia/Tokyo]"

Since an Instant has no calendar, you can only add or subtract units of fixed length (hours and smaller):

instant.add({ hours: 24 }); // Fine
instant.add({ days: 1 }); // RangeError: a "day" isn't fixed length without a zone

That error encodes a real truth: a day is 23 or 25 hours long when the clocks change.


ZonedDateTime: Time Zones Done Right

ZonedDateTime is an exact moment plus a time zone plus a calendar. It’s the most capable Temporal type and the one to use for anything a human schedules.

const meeting = Temporal.ZonedDateTime.from(
"2026-11-05T15:00:00[Europe/Berlin]",
);
meeting.timeZoneId; // "Europe/Berlin"
meeting.offset; // "+01:00"
meeting.hour; // 15
meeting.hoursInDay; // 24
meeting.toInstant(); // The exact moment

Converting Between Time Zones

const meeting = Temporal.ZonedDateTime.from(
"2026-11-05T15:00:00[Europe/Berlin]",
);
meeting.withTimeZone("America/New_York").toPlainTime().toString(); // "09:00:00"
meeting.withTimeZone("Asia/Kolkata").toPlainTime().toString(); // "19:30:00"

withTimeZone() keeps the same moment and changes how it’s displayed. That’s exactly what a “show this meeting in my time zone” feature needs.

Daylight Saving Time

DST transitions create two awkward cases:

  • Gaps: in spring, clocks jump forward and some wall-clock times don’t exist
  • Overlaps: in autumn, clocks fall back and some wall-clock times happen twice

In Europe on 2026-03-29, clocks jump from 02:00 to 03:00. In 2026-10-25, they fall back from 03:00 to 02:00. Temporal makes you decide what to do with those times through the disambiguation option:

// 02:30 doesn't exist on 2026-03-29 in Berlin
const gap = {
timeZone: "Europe/Berlin",
year: 2026,
month: 3,
day: 29,
hour: 2,
minute: 30,
};
Temporal.ZonedDateTime.from(gap); // 03:30+02:00 ("compatible", the default)
Temporal.ZonedDateTime.from(gap, { disambiguation: "earlier" }); // 01:30+01:00
Temporal.ZonedDateTime.from(gap, { disambiguation: "later" }); // 03:30+02:00
Temporal.ZonedDateTime.from(gap, { disambiguation: "reject" }); // RangeError
// 02:30 happens twice on 2026-10-25 in Berlin
const overlap = {
timeZone: "Europe/Berlin",
year: 2026,
month: 10,
day: 25,
hour: 2,
minute: 30,
};
Temporal.ZonedDateTime.from(overlap); // 02:30+02:00 (first occurrence)
Temporal.ZonedDateTime.from(overlap, { disambiguation: "later" }); // 02:30+01:00

The default, "compatible", matches what Date and most other systems do, so it’s a sensible choice. Use "reject" when you’d rather ask the user than guess.

hoursInDay tells you how long a particular day actually is:

Temporal.ZonedDateTime.from("2026-03-29T12:00[Europe/Berlin]").hoursInDay; // 23
Temporal.ZonedDateTime.from("2026-10-25T12:00[Europe/Berlin]").hoursInDay; // 25

Time Zone Rule Changes

Governments change time zone rules, sometimes with little notice. If you store a future event as 2027-06-01T10:00:00+03:00[Europe/Istanbul] and the rules change, the stored offset and the time zone now disagree. The offset option controls how parsing resolves that conflict:

Temporal.ZonedDateTime.from(stored, { offset: "prefer" }); // Default: use offset if still valid, else keep wall time
Temporal.ZonedDateTime.from(stored, { offset: "ignore" }); // Keep the wall-clock time (10:00 local)
Temporal.ZonedDateTime.from(stored, { offset: "use" }); // Keep the exact moment
Temporal.ZonedDateTime.from(stored, { offset: "reject" }); // Throw on mismatch

For a calendar app, "ignore" is usually right: a 10:00 meeting should still be at 10:00 after the rules change.


Date Arithmetic

Temporal arithmetic is calendar-aware and DST-aware. Use add() and subtract() with a duration or property bag:

const date = Temporal.PlainDate.from("2026-10-27");
date.add({ days: 7 }); // 2026-11-03
date.add({ months: 1 }); // 2026-11-27
date.subtract({ years: 1, days: 1 }); // 2025-10-26
date.add({ weeks: 2 }); // 2026-11-10

Month-End Overflow

Adding a month to January 31st has no perfect answer. Temporal constrains by default:

const jan31 = Temporal.PlainDate.from("2026-01-31");
jan31.add({ months: 1 }); // 2026-02-28
jan31.add({ months: 1 }, { overflow: "reject" }); // RangeError

Be careful when generating a recurring monthly schedule. Adding a month repeatedly to the previous result drifts (Jan 31 → Feb 28 → Mar 28). Always add from the original start date instead:

const start = Temporal.PlainDate.from("2026-01-31");
// ❌ Drifts to the 28th after February
let current = start;
const drifting = [];
for (let i = 0; i < 4; i++) {
drifting.push(current);
current = current.add({ months: 1 });
}
// ✅ Stays on the last valid day of each month
const correct = Array.from({ length: 4 }, (_, i) => start.add({ months: i }));
// 2026-01-31, 2026-02-28, 2026-03-31, 2026-04-30

Adding Days Across DST

With a ZonedDateTime, adding a day keeps the same wall-clock time, while adding 24 hours adds exact time:

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

A daily reminder at noon should use days. A 24-hour token expiry should use hours.

Differences with until() and since()

const today = Temporal.PlainDate.from("2026-10-27");
const launch = Temporal.PlainDate.from("2027-03-15");
today.until(launch).toString(); // "P139D"
today.until(launch, { largestUnit: "month" }).toString(); // "P4M16D"
today.until(launch, { largestUnit: "year" }).days; // 16
launch.since(today).days; // 139

Without largestUnit, PlainDate differences are expressed in days, since months and years vary in length. Ask for bigger units explicitly.

A practical example, calculating someone’s age:

function getAge(birthday, today = Temporal.Now.plainDateISO()) {
return birthday.until(today, { largestUnit: "year" }).years;
}
getAge(Temporal.PlainDate.from("1990-10-28")); // 35 on 2026-10-27

Start and End of Periods

const now = Temporal.Now.zonedDateTimeISO("Europe/Berlin");
now.startOfDay(); // Midnight (or whenever the day starts in that zone)
now.with({ day: 1 }).startOfDay(); // Start of the month
const date = now.toPlainDate();
const monday = date.subtract({ days: date.dayOfWeek - 1 }); // Start of ISO week
const sunday = monday.add({ days: 6 }); // End of ISO week

startOfDay() matters because some time zones skip midnight during DST transitions. Hard-coding with({ hour: 0 }) can land on a time that doesn’t exist.


Durations

Temporal.Duration represents a length of time, in ISO 8601 duration format:

const d1 = Temporal.Duration.from({ hours: 1, minutes: 30 });
const d2 = Temporal.Duration.from("PT1H30M");
d1.toString(); // "PT1H30M"
d1.hours; // 1
d1.minutes; // 30
d1.sign; // 1 (or -1, or 0)
d1.negated().toString(); // "-PT1H30M"
d1.abs();

Converting with total()

const d = Temporal.Duration.from({ hours: 2, minutes: 45 });
d.total({ unit: "minute" }); // 165
d.total({ unit: "hour" }); // 2.75

Balancing with round()

Durations aren’t automatically normalized. 90 minutes stays as 90 minutes until you ask:

const d = Temporal.Duration.from({ minutes: 90 });
d.round({ largestUnit: "hour" }).toString(); // "PT1H30M"

Calendar Units Need a Reference

How many days is one month? It depends which month. Any operation that mixes calendar units (years, months, weeks) with fixed units needs relativeTo:

const oneMonth = Temporal.Duration.from({ months: 1 });
oneMonth.total({ unit: "day" }); // RangeError
oneMonth.total({ unit: "day", relativeTo: "2026-02-01" }); // 28
oneMonth.total({ unit: "day", relativeTo: "2026-03-01" }); // 31

Formatting Durations

Duration.prototype.toLocaleString() uses Intl.DurationFormat:

const d = Temporal.Duration.from({ hours: 1, minutes: 5, seconds: 30 });
d.toLocaleString("en", { style: "long" }); // "1 hour, 5 minutes, 30 seconds"
d.toLocaleString("en", { style: "short" }); // "1 hr, 5 min, 30 sec"
d.toLocaleString("en", { style: "digital" }); // "1:05:30"
d.toLocaleString("de", { style: "long" }); // "1 Stunde, 5 Minuten und 30 Sekunden"

Comparing and Sorting

Every type has a static compare() that returns -1, 0, or 1, which plugs straight into Array.prototype.sort:

const dates = ["2026-12-01", "2026-01-15", "2026-07-04"].map((s) =>
Temporal.PlainDate.from(s),
);
dates.sort(Temporal.PlainDate.compare);
// [2026-01-15, 2026-07-04, 2026-12-01]

Instances have an equals() method:

const a = Temporal.PlainDate.from("2026-10-27");
const b = Temporal.PlainDate.from({ year: 2026, month: 10, day: 27 });
a === b; // false (different objects)
a.equals(b); // true

Relational Operators Throw

This is the biggest habit to break when coming from Date:

const a = Temporal.PlainDate.from("2026-10-27");
const b = Temporal.PlainDate.from("2026-11-01");
a < b; // TypeError: Temporal values can't be compared with < or >

Temporal objects deliberately throw from valueOf(). With Date, < works by comparing milliseconds, but for something like PlainDate there’s no single number to compare that would be correct across calendars. Use compare() instead.

ZonedDateTime.equals() is strict: two values representing the same instant in different time zones aren’t equal. To compare moments, compare their instants:

const berlin = Temporal.ZonedDateTime.from("2026-10-27T10:00[Europe/Berlin]");
const london = berlin.withTimeZone("Europe/London");
berlin.equals(london); // false (different zones)
berlin.toInstant().equals(london.toInstant()); // true (same moment)
Temporal.ZonedDateTime.compare(berlin, london); // 0 (compare() only looks at the moment)

Rounding

Time values and durations support round() with a unit and rounding mode:

const time = Temporal.PlainTime.from("14:37:52");
time.round({ smallestUnit: "minute" }).toString(); // "14:38:00"
time.round({ smallestUnit: "minute", roundingIncrement: 15 }).toString(); // "14:45:00"
time.round({ smallestUnit: "hour", roundingMode: "ceil" }).toString(); // "15:00:00"
time.round({ smallestUnit: "hour", roundingMode: "floor" }).toString(); // "14:00:00"

That roundingIncrement is handy for booking UIs that snap to 15-minute slots:

function nextSlot(now = Temporal.Now.zonedDateTimeISO()) {
return now.round({
smallestUnit: "minute",
roundingIncrement: 15,
roundingMode: "ceil",
});
}

You can also control precision when converting to strings:

const instant = Temporal.Now.instant();
instant.toString(); // "2026-10-27T09:30:00.123456789Z"
instant.toString({ smallestUnit: "second" }); // "2026-10-27T09:30:00Z"
instant.toString({ fractionalSecondDigits: 3 }); // "2026-10-27T09:30:00.123Z"

Formatting for Users

toString() gives you ISO 8601 for machines. For humans, use toLocaleString(), which accepts the same options as Intl.DateTimeFormat:

const meeting = Temporal.ZonedDateTime.from(
"2026-11-05T15:00:00[Europe/Berlin]",
);
meeting.toLocaleString("en-US");
// "11/5/2026, 3:00:00 PM GMT+1"
meeting.toLocaleString("en-GB", {
dateStyle: "full",
timeStyle: "short",
});
// "Thursday, 5 November 2026 at 15:00"
Temporal.PlainDate.from("2026-10-27").toLocaleString("de-DE", {
weekday: "long",
day: "numeric",
month: "long",
});
// "Dienstag, 27. Oktober"

A ZonedDateTime formats in its own time zone. Plain types format with no time zone conversion at all, which is exactly why a PlainDate birthday never shifts.

You can also pass Temporal objects directly to an Intl.DateTimeFormat instance, which is faster when formatting many values:

const formatter = new Intl.DateTimeFormat("en-US", { dateStyle: "medium" });
dates.map((date) => formatter.format(date));

Relative Time

Combine until() with Intl.RelativeTimeFormat for “in 3 days” labels:

const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
function relativeDay(date, today = Temporal.Now.plainDateISO()) {
const days = today.until(date).days;
return rtf.format(days, "day");
}
relativeDay(Temporal.PlainDate.from("2026-10-28")); // "tomorrow"
relativeDay(Temporal.PlainDate.from("2026-10-30")); // "in 3 days"
relativeDay(Temporal.PlainDate.from("2026-10-24")); // "3 days ago"

Serialization and Storage

JSON

Every Temporal type has a toJSON() method that returns its ISO string, so JSON.stringify just works:

const event = {
title: "Launch",
date: Temporal.PlainDate.from("2027-03-15"),
startsAt: Temporal.ZonedDateTime.from("2027-03-15T09:00[America/New_York]"),
};
JSON.stringify(event);
// {"title":"Launch","date":"2027-03-15","startsAt":"2027-03-15T09:00:00-04:00[America/New_York]"}

Parsing back requires knowing which type each field is. A reviver keyed on field names keeps that explicit:

const temporalFields = {
date: Temporal.PlainDate,
startsAt: Temporal.ZonedDateTime,
};
const parsed = JSON.parse(json, (key, value) =>
temporalFields[key] ? temporalFields[key].from(value) : value,
);

In a typed codebase, a validation library like Zod at the API boundary is a cleaner place for this conversion.

The Bracketed Time Zone

The [America/New_York] annotation is part of RFC 9557, an extension to the ISO 8601 / RFC 3339 format. Many tools that expect plain RFC 3339 won’t understand it. When sending to such a system, send an Instant string and the zone as a separate field:

const payload = {
startsAt: meeting.toInstant().toString(), // "2027-03-15T13:00:00Z"
timeZone: meeting.timeZoneId, // "America/New_York"
};
// Reconstruct
Temporal.Instant.from(payload.startsAt).toZonedDateTimeISO(payload.timeZone);

Databases

Map each Temporal type to a column that preserves its meaning:

Temporal typePostgreSQL columnNotes
InstanttimestamptzStored as UTC
ZonedDateTimetimestamptz + text time zone columnPostgres doesn’t store the zone name
PlainDatedate
PlainTimetime
PlainDateTimetimestamp (without time zone)
Durationinterval or text (ISO string)text round-trips exactly

For future events, consider storing the wall-clock time and zone rather than the instant. If time zone rules change before the event, recomputing from 2027-06-01T10:00 + Europe/Istanbul gives the time the user intended. For past events, the instant is the source of truth. See our guide to PostgreSQL vs MySQL vs SQLite for how each database handles timestamps.


Migrating from Date

You don’t need to rewrite everything at once. Temporal and Date interoperate through epoch milliseconds.

Converting Between Them

// Date → Temporal
const legacy = new Date();
const instant = legacy.toTemporalInstant();
const zoned = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId());
// Temporal → Date
const backToDate = new Date(instant.epochMilliseconds);
const fromZoned = new Date(zoned.epochMilliseconds);

Going back to Date loses the time zone and anything below millisecond precision, so convert at the edges only when a library requires it.

Common Translations

Date / libraryTemporal
Date.now()Temporal.Now.instant().epochMilliseconds
new Date()Temporal.Now.zonedDateTimeISO()
new Date("2026-10-27") (as a date)Temporal.PlainDate.from("2026-10-27")
date.getMonth() + 1date.month
date.getDay() (Sunday = 0)date.dayOfWeek % 7 (Temporal: Monday = 1, Sunday = 7)
date.setDate(date.getDate() + 1)date.add({ days: 1 })
date.toISOString()instant.toString()
a.getTime() < b.getTime()Temporal.Instant.compare(a, b) < 0
date-fns differenceInDays(b, a)a.until(b).days
date-fns startOfMonth(d)d.with({ day: 1 })
date-fns isSameDay(a, b)a.toPlainDate().equals(b.toPlainDate())
Moment moment.tz(str, zone)Temporal.PlainDateTime.from(str).toZonedDateTime(zone)
Luxon DateTime.fromISO(s).setZone(z)Temporal.ZonedDateTime.from(s).withTimeZone(z)

A Migration Strategy

  1. Start at the boundaries. Parse incoming API data into Temporal types and convert back to strings on the way out.
  2. Pick the right type per field. Go through your data model and ask “is this a moment, a calendar date, or a scheduled time?” This is the most valuable part of the migration, and it usually surfaces existing bugs.
  3. Replace date library calls module by module. Your tests are your safety net here, so run them across multiple time zones (for example TZ=America/Los_Angeles npm test and TZ=Asia/Kolkata npm test).
  4. Keep Date only where a third-party library demands it, and convert right before the call.
  5. Drop the date library once nothing imports it. Moment.js alone is a large chunk of many bundles.

Browser Support and Polyfills

Temporal shipped in Firefox 139 (2025) and Chrome 144 (early 2026), and is available in other Chromium-based browsers and runtimes built on matching V8 versions. Safari support has been in progress for a while, so check caniuse.com for current status before relying on the native implementation for all your users.

Until support is universal, use a polyfill. There are two main options:

PolyfillNotes
@js-temporal/polyfillMaintained by the proposal’s champions, closest to spec
temporal-polyfillMuch smaller bundle, spec-compliant, good for front-ends

Import explicitly so it’s obvious which implementation you’re using:

import { Temporal } from "temporal-polyfill";

Or install it globally only when the native version is missing:

temporal.js
if (typeof globalThis.Temporal === "undefined") {
await import("temporal-polyfill/global");
}

Load that file before the rest of your app, and the polyfill only downloads for browsers that need it.

TypeScript

Recent TypeScript versions include Temporal type definitions in the esnext lib. If your version doesn’t, the polyfill packages ship their own types:

{
"compilerOptions": {
"lib": ["ESNext", "DOM"]
}
}

Temporal’s types catch whole categories of bugs at compile time. A function that accepts Temporal.PlainDate can’t be accidentally called with an Instant. For more on modeling domain types precisely, see our guide to advanced TypeScript patterns.


Common Pitfalls

Pitfall 1: Using PlainDateTime as a Moment

// ❌ Which 9:00? This isn't a point in time
const reminder = Temporal.PlainDateTime.from("2026-11-05T09:00");
scheduleJob(reminder);
// ✅ Attach the user's time zone
const reminder = Temporal.PlainDateTime.from(
"2026-11-05T09:00",
).toZonedDateTime(user.timeZone);
scheduleJob(reminder.toInstant());

If you find yourself converting a PlainDateTime with the server’s time zone, it’s almost always a bug. The server’s zone has nothing to do with the user’s intent.

Pitfall 2: Forgetting Immutability

// ❌ Return value discarded
const date = Temporal.PlainDate.from("2026-10-27");
date.add({ days: 1 });
console.log(date.toString()); // Still 2026-10-27
// ✅ Use the returned value
const tomorrow = date.add({ days: 1 });

Pitfall 3: Comparing with < and >

// ❌ TypeError
if (deadline < today) { ... }
// ✅
if (Temporal.PlainDate.compare(deadline, today) < 0) { ... }

Pitfall 4: Reading the Wrong Duration Field

const d = Temporal.PlainDate.from("2026-01-01").until("2026-03-15", {
largestUnit: "month",
});
d.days; // 14, not 73! The rest is in d.months
d.total({ unit: "day", relativeTo: "2026-01-01" }); // 73

Fields are components, not totals. Use total() when you want a single number.

Pitfall 5: Mixing Temporal Implementations

If one part of your app uses the polyfill’s Temporal and another uses the native global, objects from one may not pass instanceof checks in the other. Pick one approach (explicit import or conditional global) and use it everywhere.

Pitfall 6: Assuming Days Are 24 Hours

// ❌ Wrong on DST transition days
const tomorrow = zoned.add({ hours: 24 });
// ✅ Calendar day
const tomorrow = zoned.add({ days: 1 });

Best Practices

  1. Choose the type from the meaning of the data: Instant for “when it happened”, ZonedDateTime for “when it’s scheduled”, PlainDate for calendar dates
  2. Default to PlainDate for dates without times: birthdays, due dates, and holidays shouldn’t carry a time zone
  3. Store the user’s IANA time zone (Intl.DateTimeFormat().resolvedOptions().timeZone), never a fixed offset like +01:00
  4. Use overflow: "reject" when validating input, and the default "constrain" for arithmetic
  5. Add calendar units for human schedules (days, months) and exact units for technical ones (hours, seconds)
  6. Format with toLocaleString(), not hand-built strings
  7. Convert to Date only at library boundaries, as late as possible
  8. Test in multiple time zones, including one with a half-hour offset and one in the southern hemisphere
  9. Pass a fixed “now” into functions instead of calling Temporal.Now inside them, so they’re easy to test
  10. Load a polyfill conditionally until Temporal is available in every browser you support

Conclusion

Temporal fixes JavaScript’s longest-running API problem. Instead of one mutable type that pretends every value is a UTC timestamp, it gives you a set of immutable types that match how people actually think about time: moments, calendar dates, wall-clock times, and durations.

Key Takeaways:

  • Temporal values are immutable and their months are 1-indexed
  • Exact time (Instant, ZonedDateTime) and wall-clock time (Plain* types) are separate, and Temporal won’t let you mix them up by accident
  • ZonedDateTime handles DST correctly, with disambiguation for gaps and overlaps
  • Arithmetic is calendar-aware: add({ days: 1 }) and add({ hours: 24 }) mean different things
  • Use compare() and equals(); < and > throw
  • Serialize with ISO strings and pick database columns that preserve each type’s meaning
  • Migrate at the boundaries first, and use a polyfill until browser support is complete

Most date bugs come from not knowing what kind of value you’re holding. The real benefit of Temporal is that it makes you decide up front. For more on how JavaScript has evolved, see our overview of modern JavaScript features.

Next Steps:

  1. Open your browser console and try Temporal.Now.zonedDateTimeISO().toString()
  2. Audit your data model and label each date field as a moment, a calendar date, or a scheduled time
  3. Add a Temporal polyfill and convert one module that does date arithmetic
  4. Run your test suite under two or three different TZ values

Happy time traveling! ⏰