Temporal in JavaScript: PlainDate, ZonedDateTime, Instant, Durations and Replacing Date
Temporal, the modern date and time API added in ES2027: why Date wasn't enough, choosing between Instant, ZonedDateTime and the Plain types, immutable arithmetic that handles month ends and daylight saving time, Durations, comparing and sorting, converting from Date, support status and polyfills.
kvi5hnuCode Sprout team member7 min readOn this page
Article 83 showed Date's problems: mutable objects, 0-based months, one type for everything, confusing parsing, and no real time zone support. Temporal is the long-awaited replacement. It reached Stage 4 in 2026 and is part of ES2027. Chrome, Edge and Firefox ship it; at the time of writing, Safari and Node.js are still catching up, so check support for your targets and use the polyfill where needed (see the end of this article).
Because Temporal isn't available in every environment yet, the examples here are plain code blocks with their results shown in comments. Each result was verified with the official reference polyfill.
Temporal's design in four points
- Separate types for separate ideas. A birthday, a meeting, a timestamp and "2 hours" are different things, so each gets its own type.
- Immutable. Every operation returns a new object; nothing is changed in place.
- Human numbering. Months are 1 to 12. Days of the week are 1 (Monday) to 7 (Sunday), following ISO 8601.
- Explicit time zones and calendars. Real IANA time zones (
"Asia/Kolkata") with daylight saving time rules, and support for non-Gregorian calendars.
All of it lives on the global Temporal namespace object, like Math or Intl.

Choosing a type
| You have... | Use | Example |
|---|---|---|
| An exact moment (a log entry, a payment) | Temporal.Instant | 2026-11-18T14:30:00Z |
| A moment as people in a place experience it (a meeting, a flight) | Temporal.ZonedDateTime | 2026-11-18T09:30-05:00[America/New_York] |
| A calendar date with no time (birthday, due date, holiday) | Temporal.PlainDate | 2026-11-18 |
| A clock time with no date (opening hours, a daily alarm) | Temporal.PlainTime | 09:30 |
| A date and time, but no zone yet (form input) | Temporal.PlainDateTime | 2026-11-18T09:30 |
| A month (billing period, credit card expiry) | Temporal.PlainYearMonth | 2026-11 |
| A yearly date (anniversary) | Temporal.PlainMonthDay | 12-25 |
| An amount of time | Temporal.Duration | P1M15D, PT2H30M |
Plain types have no time zone, so they can't be placed on the global timeline until you supply one. That's exactly what you want for a birthday: November 18 is November 18 everywhere.
PlainDate: calendar dates without surprises
const due = Temporal.PlainDate.from("2026-01-31");
due.month; // 1 (January is 1, not 0)
due.dayOfWeek; // 6 (Saturday; Monday is 1)
due.daysInMonth; // 31
due.inLeapYear; // false
due.add({ months: 1 }).toString(); // "2026-02-28": clamped to the last valid day
due.add({ months: 1 }, { overflow: "reject" }); // throws RangeError
Temporal.PlainDate.from({ year: 2026, month: 2, day: 30 }).toString(); // "2026-02-28"
Compare that with Date, where "add a month to January 31" silently gives March 3. Temporal constrains to the nearest valid date by default, or throws if you pass { overflow: "reject" }.
There's also no UTC trap: Temporal.PlainDate.from("2026-11-18") is November 18 for every user, in every zone.
Differences, comparison and sorting
const today = Temporal.PlainDate.from("2026-11-18");
const holiday = Temporal.PlainDate.from("2026-12-25");
today.until(holiday).toString(); // "P37D"
today.until(holiday).days; // 37
today.until(holiday, { largestUnit: "months" }).toString(); // "P1M7D"
Temporal.PlainDate.compare(today, holiday); // -1
today.equals(Temporal.PlainDate.from("2026-11-18")); // true
[holiday, today].sort(Temporal.PlainDate.compare).join(" "); // "2026-11-18 2026-12-25"
today.with({ day: 1 }).toString(); // "2026-11-01" (start of month)
untilandsincereturn aDuration;largestUnitcontrols whether you get days or months and days.compareis a ready-made sort comparator.equalscompares values.withreturns a copy with some fields replaced.<and>deliberately throw a TypeError on Temporal objects (theirvalueOfthrows), so you can't compare them by accident in a way that silently does the wrong thing.
ZonedDateTime: moments in a time zone
A ZonedDateTime is an exact instant plus a time zone (and calendar). It knows the zone's offset and daylight saving time rules, so it can do arithmetic the way people expect:
const meeting = Temporal.ZonedDateTime.from("2026-11-18T09:30[America/New_York]");
meeting.toString(); // "2026-11-18T09:30:00-05:00[America/New_York]"
meeting.offset; // "-05:00"
meeting.withTimeZone("Asia/Kolkata").toString(); // "2026-11-18T20:00:00+05:30[Asia/Kolkata]"
meeting.toInstant().toString(); // "2026-11-18T14:30:00Z"
withTimeZone answers "what time is this meeting for my colleague in Kolkata?" without any manual offset math.
Daylight saving time done right
In the United States, clocks moved forward on March 8, 2026, so that day had only 23 hours:
const saturdayNoon = Temporal.ZonedDateTime.from("2026-03-07T12:00[America/New_York]");
saturdayNoon.add({ days: 1 }).toString(); // "2026-03-08T12:00:00-04:00[America/New_York]"
saturdayNoon.add({ hours: 24 }).toString(); // "2026-03-08T13:00:00-04:00[America/New_York]"
Adding 1 day keeps the same wall-clock time (noon to noon), while adding 24 hours adds exact elapsed time, which ends at 1 p.m. Temporal makes you say which you mean; with Date you'd have to know about the DST change yourself.
Instant: exact time
Temporal.Instant is the closest equivalent of a Date: a point on the timeline with nanosecond precision, no zone, no calendar:
const at = Temporal.Instant.from("2026-11-18T09:30:00Z");
at.epochMilliseconds; // 1794994200000
at.toZonedDateTimeISO("Asia/Tokyo").toString(); // "2026-11-18T18:30:00+09:00[Asia/Tokyo]"
Temporal.Now.instant(); // the current instant
Use Instant for timestamps in logs, databases and APIs. Convert to a ZonedDateTime when you need to show it to people or do calendar math.
PlainTime, PlainDateTime and friends
Temporal.PlainTime.from("23:30").add({ hours: 2 }).toString(); // "01:30:00" (wraps around)
const local = Temporal.PlainDateTime.from("2026-11-18T09:30"); // e.g. from a form
local.toZonedDateTime("Europe/London").toString();
// "2026-11-18T09:30:00+00:00[Europe/London]"
Temporal.PlainYearMonth.from("2026-02").daysInMonth; // 28
Temporal.PlainMonthDay.from("02-29").toPlainDate({ year: 2027 }).toString(); // "2027-02-28"
The last line handles leap-day birthdays in non-leap years by clamping to February 28.
Duration
Temporal.Duration represents an amount of time in ISO 8601 duration format (P for period, T before time units):
const d = Temporal.Duration.from({ hours: 1, minutes: 90 });
d.toString(); // "PT1H90M"
d.round({ largestUnit: "hours" }).toString(); // "PT2H30M"
d.total("minutes"); // 150
Temporal.Duration.from("P1Y2M3DT4H").toString(); // "P1Y2M3DT4H"
Temporal.Duration.from({ days: 45 })
.round({ largestUnit: "months", relativeTo: Temporal.PlainDate.from("2026-11-18") })
.toString(); // "P1M15D"
Balancing days into months needs a relativeTo date, because months have different lengths. That's the kind of detail Temporal makes explicit instead of guessing. Durations format nicely for people with Intl.DurationFormat (article 85).
Formatting, JSON and the current time
Temporal.PlainDate.from("2026-11-18").toLocaleString("en-US", { dateStyle: "long" });
// "November 18, 2026"
JSON.stringify({ due: Temporal.PlainDate.from("2026-11-18") }); // '{"due":"2026-11-18"}'
Temporal.Now.plainDateISO(); // today's date in the system time zone
Temporal.Now.zonedDateTimeISO("UTC"); // now, in a chosen zone
Temporal.Now.timeZoneId(); // e.g. "Europe/Berlin"
Temporal objects serialize to their ISO strings, and you rebuild them with the matching from().
Converting between Date and Temporal
const legacy = new Date(Date.UTC(2026, 10, 18, 9, 30));
const instant = Temporal.Instant.fromEpochMilliseconds(legacy.getTime());
// or, where Temporal is built in: legacy.toTemporalInstant()
const backToDate = new Date(instant.epochMilliseconds);
backToDate.toISOString(); // "2026-11-18T09:30:00.000Z"
Many APIs (the DOM, older libraries, database drivers) still use Date, so convert at the boundaries and use Temporal inside your own logic.
Support and polyfills
- Browsers: Firefox (since 139) and Chrome/Edge (since 144) ship Temporal. Safari support is in progress.
- Node.js: follows V8; check
typeof Temporalin your version. - Polyfills:
@js-temporal/polyfill(the reference implementation from the proposal champions) andtemporal-polyfill(smaller). Import{ Temporal }from one of them and the code in this article runs unchanged. - TypeScript: both polyfills ship type definitions, so you get full type checking even before your target environments support Temporal natively.
// feature-detect, falling back to a polyfill
const { Temporal } = globalThis.Temporal
? globalThis
: await import("@js-temporal/polyfill");
Common questions
Should I stop using Date?
For new date logic, prefer Temporal wherever it's available or polyfilled. Date isn't going away, so you'll still use it with APIs that require it, converting at the boundary.
Why are there so many types?
Because "a date" means different things. A birthday has no time zone, a meeting does, a log timestamp is an exact instant, and "3 days" is an amount. Mixing them in one type is what caused most Date bugs.
Do I still need date-fns, Luxon or Moment?
Moment.js is in maintenance mode and not recommended for new code. Temporal covers most of what date libraries were used for (parsing ISO strings, arithmetic, time zones, durations). Libraries remain useful for custom parsing formats and for environments without Temporal.
What does [America/New_York] in the string mean?
It's the IANA time zone annotation (from RFC 9557). The offset (-05:00) records the offset at that moment, and the bracketed zone lets Temporal apply future DST rules correctly when you do arithmetic.
Summary
- Temporal (ES2027) replaces
Datewith immutable, purpose-specific types and 1-based months. Instantis an exact moment;ZonedDateTimeis an instant in a time zone, with DST-aware arithmetic.PlainDate,PlainTime,PlainDateTime,PlainYearMonthandPlainMonthDayrepresent calendar and clock values without a zone.Durationrepresents amounts of time;until/sinceproduce durations;roundandtotalconvert them.- Month-end arithmetic clamps (or rejects); adding days vs hours differs across DST changes.
- Compare with
compareandequals(not<), serialize as ISO strings, convert fromDatevia epoch milliseconds, and use a polyfill where Temporal isn't built in yet.
Practice Questions
Which Temporal type would you use for (a) a user's date of birth, (b) when a payment was processed, (c) a recurring 07 alarm, (d) a video call scheduled for colleagues in two countries?
Answer
(a) PlainDate, (b) Instant, (c) PlainTime, (d) ZonedDateTime (stored with the organizer's zone and converted with withTimeZone for each participant).
What does this return?
Temporal.PlainDate.from("2026-03-31").subtract({ months: 1 }).toString()
Answer
"2026-02-28". February has no 31st, so the result is constrained to the last day of February.
Why does dateA < dateB throw for Temporal objects, and what should you use?
Answer
Temporal types throw from valueOf to prevent accidental numeric or string comparisons. Use Temporal.PlainDate.compare(a, b) < 0 (or the compare of the relevant type), or a.equals(b).
How many hours are between 2026-03-07T12:00[America/New_York] and .add({ days: 1 }) of it?
Answer
23 hours. The result is noon the next day, and that day lost an hour to the daylight saving time change.
Previous: JavaScript Dates: the Date Object, Timestamps, Time Zones, Date Arithmetic and Formatting
Next: JavaScript Intl: Formatting Numbers, Currencies, Dates, Relative Times and Durations for Any Locale

More in JavaScript Course
Quiz: Modern JavaScript, ES2022 to ES2027 Features
Twenty-four questions on what's new in JavaScript: change-array-by-copy methods, groupBy, Set methods, iterator helpers, Promise.withResolvers and Promise.try, RegExp.escape and the v flag, using declarations, Error.isError, Base64 typed arrays, Temporal, getOrInsert and Iterator.zip.
Quiz: JavaScript's Delicate Details (Spec-Level Edge Cases)
Twenty-eight questions on the fine print of JavaScript, drawn from the ECMAScript specification and MDN: sparse arrays, -0, number limits, JSON edge cases, Date overflow, UTF-16, property attributes, inherited accessors, comparison quirks, labels, regex state and Symbol.toPrimitive.
Quiz: JavaScript Interview Questions (Output Prediction and Core Concepts)
Thirty classic JavaScript interview questions: closures in loops, hoisting and the TDZ, this, the event loop and microtasks, async/await, coercion, sorting and parseInt traps, prototypes, copying, finally, generators and bind. Every answer was verified by running it.
Quiz: JavaScript Course Final Exam (All 17 Parts)
The final exam for the JavaScript course: thirty questions spanning all seventeen parts, from syntax, types and operators through objects, arrays, functions, classes, modules, the standard library, iterators, async code, metaprogramming, browsers, Node.js and tooling.
Discussion
Sign in to ask a question or share what you learned.