Loading Temporal polyfill…
Mutability: Date vs Temporalwatch the original
// pass each into addWeek() — does the original change? function addWeek(d) { // Date: d.setDate(d.getDate()+7) ← mutates! // Temporal: d.add({ days: 7 }) ← returns new }
// press run to compare…
Date is mutable. A function that receives a Date can silently change your original — a classic source of "impossible" bugs. Every Temporal object is immutable: math returns a new object, the original is never touched.
Pick the right type
// click a use case to see the type + live code…
The DST trap. On 2026-03-29, London springs forward: the clock jumps 01:00 → 02:00, so 01:30 never exists. On 2026-10-25 it falls back and 01:30 happens twice. Date silently invented an answer. Temporal makes you choose.
Scenario
Strategy
// choose a scenario and strategy…
One instant, five cities
Base (NYC)
Every row is the same instant on the global timeline — one ZonedDateTime, converted with a single withTimeZone() call each.
Date difference calculator
From
To
// pick two dates…
const diff = from.until(to, { largestUnit: 'year' }); // → Duration { years, months, days }
until() and since() return a Duration, not raw milliseconds — ask for any largestUnit you want.