Project 50, Developer tools
Temporal Date and Time Toolkit
Convert a meeting time across cities, count the days until a deadline, or decode a Unix timestamp. Temporal fixes the old Date object's time zone headaches.
- Main API
- Temporal
- Fallback
- temporal-polyfill 1.0.5
- Dependencies
- Polyfill only when needed
- Your browser
- Checking
Date and time tools
Loading Temporal
How it works
- Use the right typePlainDate for calendar days, ZonedDateTime for a moment in a place, Instant for an exact point on the timeline.
- Convert zonesOne ZonedDateTime is moved to other zones with withTimeZone(). The clock time changes, the moment does not.
- Do math safelyuntil() and add() understand months of different lengths and daylight saving, so 1 month after 31 January is 28 or 29 February.
import { Temporal } from "https://cdn.jsdelivr.net/npm/temporal-polyfill@1.0.5/+esm"; // only if not built in
const meeting = Temporal.ZonedDateTime.from("2026-10-26T09:00[America/New_York]");
meeting.withTimeZone("Asia/Dhaka").toString(); // 2026-10-26T19:00:00+06:00[Asia/Dhaka]
const until = Temporal.PlainDate.from("2026-09-23").until("2026-12-25", { largestUnit: "month" });
until.toString(); // "P3M2D": 3 months, 2 days
Temporal.PlainDate.from("2026-01-31").add({ months: 1 }).toString(); // "2026-02-28"