Productivity is the result of a commitment to excellence, intelligent planning, and focused effort.

Start using the Temporal API- Javascript

Cover Image for Start using the Temporal API- Javascript
George Crisan
George Crisan
Posted on:

JavaScript gets a predictable, timezone-aware, DST-safe date and time API and is available in the current version of Chrome, Safari (with useTemporal flag) and Node.js 23+.

For latest support see Temporal API support - https://caniuse.com/temporal

This article is a complete practical guide showing how to:

  1. - Get the current time in UTC and timezones
  2. - Work with ZonedDateTime, Instant, PlainDate, and Duration
  3. - Add or subtract time correctly
  4. - Convert between time zones

All with zero polyfills.

Getting the current time

const now = Temporal.Now.instant();
console.log(now.toString());

// Example: "2026-03-22T09:15:33.112345678Z"

Getting time in UTC vs BST

This is where Temporal shows its use, no libraries, no “is DST right now?” code.

Current time UTC

const utc = Temporal.Now.zonedDateTimeISO("UTC");
console.log(utc.toString());

// 2026-03-22T10:48:03.608155029+00:00[UTC] <- Output

Current time BST

const bst = Temporal.Now.zonedDateTimeISO("Europe/London");
console.log(bst.toString());

// Summer: offset +01:00
// Winter: offset +00:00
// 2026-03-22T10:48:33.528074951+00:00[Europe/London] <-- Output

Adding and subtracting dates correctly

Add 6 days (remember, at the time of writing this article, the date is 2026-03-22)

const today = Temporal.Now.plainDateISO();
const next = today.add({ days: 6 });
console.log(next.toString());

// 2026-03-28 <- Output

Subtract 2 months

const today = Temporal.Now.plainDateISO();
const twoMonthsAgo = today.subtract({ months: 2 });
console.log(twoMonthsAgo.toString());

// 2026-01-22 <- Output

DST-aware time arithmetic in London

This handles the spring-forward 1-hour skip safely. If you add 1 hour on the day clocks go forward, Temporal moves to the next real available time.

const london = Temporal.Now.zonedDateTimeISO("Europe/London");
const plusHour = london.add({ hours: 1 });

Converting between time zones

const utcNow = Temporal.Now.zonedDateTimeISO("UTC");
const londonTime = utcNow.withTimeZone("Europe/London");

// Convert UTC → Romania (Bucharest)
const romanianTime = utcNow.withTimeZone("Europe/Bucharest");

console.log("UTC:", utcNow.toString());
console.log("London:", londonTime.toString());
console.log("Romania:", romanianTime.toString());

// Output:
// UTC: 2026-03-22T10:57:40.345165039+00:00[UTC]
// London: 2026-03-22T10:57:40.345165039+00:00[Europe/London]
// Romania: 2026-03-22T12:57:40.345165039+02:00[Europe/Bucharest]

or back

const backToUtc = romanianTime.withTimeZone("UTC");
console.log(backToUtc.toString());

Measuring differences between dates

The APIs until() and since() give precise durations.

const start = Temporal.PlainDate.from("2026-03-01");
const end   = Temporal.PlainDate.from("2026-03-22");

const diff = start.until(end);
console.log(diff.days); 

// 21

The Temporal API is the biggest improvement to JavaScript time handling since the language began. I am very excited about the direction the JS ecosystem and core features are taking.

Thank you for following.