Temporal API
The TC39 Temporal proposal provides a modern, immutable date/time API that fixes the many quirks of the legacy Date object. Available as a polyfill today.
The TC39 Temporal proposal provides a modern, immutable date/time API that fixes the many quirks of the legacy Date object. Available as a polyfill today.
// Using @js-temporal/polyfill
import { Temporal } from "@js-temporal/polyfill";
const today = Temporal.PlainDate.today();
// { year: 2024, month: 6, day: 15 }
const tomorrow = today.add({ days: 1 });
const inNY = Temporal.Now.zonedDateTimeISO("America/New_York");
// Duration arithmetic
const duration = Temporal.Duration.from({ hours: 5, minutes: 30 });
const later = Temporal.Now.plainTimeISO().add(duration);
Temporal is stage 3 at TC39 — use the polyfill in production today and migrate when native support lands.
More in JavaScript