Temporal — the replacement for Date, and why Node does not run it yet¶
Level: 301 · for anyone tired of the Date bugs in this chapter
Stub — an outline, not a lesson. There is no runnable example behind this page yet, so nothing on it has been through the check that backs every other claim in this library. The questions below are what the finished page has to answer.
One line: Temporal replaces Date with separate types for an instant, a calendar date and a date-time in a zone, but Node 25.2.1 does not ship it: typeof Temporal is "undefined", and --harmony-temporal does not change that.
Keywords: Temporal, Temporal.PlainDate, Temporal.ZonedDateTime, Temporal.Instant
What the finished page will answer¶
- What is
typeof Temporalin Node 24 and in Node 25.2.1, with and without--harmony-temporal? - Which Temporal type answers which question:
Instant,PlainDate,PlainDateTime,ZonedDateTime,Duration? - What does
Temporal.PlainDate.from("2026-01-31").add({ months: 1 })give, wheresetMonthgave 3 March? - What does
overflow: "reject"do with 30 February? - How does a program check for
Temporaland fall back toDatewhen it is missing?
Examples it will need¶
-
temporal_feature_check_sh.sh— node --version, then typeof Temporal with and without --harmony-temporal -
temporal_month_end_js.js— 31 January plus one month with Temporal.PlainDate when Temporal exists, and a one-line notice when it does not
See also¶
Datemonths start at zero — the Date bugs Temporal was designed to remove- Which features your Node has — checking whether this Node has a feature
- ECMAScript versions — how a proposal becomes part of the language
- Time zones — the zone handling that ZonedDateTime makes explicit
- Rust: An
Instantis not aSystemTime↗ — the same split in Rust: an instant is not a calendar time - C++: A time point knows its clock ↗ — the C++ way: the clock is part of the time point's type