Sub topic 5
Reading the Current Time with Temporal.Now
This chapter assumes you have read the type overview and the runtime support chapter. You should know what an Instant, a ZonedDateTime, and the plain types are, and you should have either native Temporal or the @js-temporal/polyfill package available. Every code block below starts with the same fallback import, so you can paste each one into an ES module file and run it.
Temporal.Now is a namespace object, not a class. You cannot construct it. It holds a small set of functions that read the host's system clock and its current time zone. Each function returns a different Temporal type. There is no all-purpose now() function, so you choose which kind of "now" you need.
The Functions in Temporal.Now
| Function | Returns | Depends on time zone? |
|---|---|---|
| `Temporal.Now.instant()` | `Temporal.Instant` | No |
| `Temporal.Now.timeZoneId()` | string, such as `'Europe/Paris'` | It is the time zone |
| `Temporal.Now.zonedDateTimeISO(tz?)` | `Temporal.ZonedDateTime` | Yes |
| `Temporal.Now.plainDateTimeISO(tz?)` | `Temporal.PlainDateTime` | Yes |
| `Temporal.Now.plainDateISO(tz?)` | `Temporal.PlainDate` | Yes |
| `Temporal.Now.plainTimeISO(tz?)` | `Temporal.PlainTime` | Yes |
The ISO suffix means the result uses the ISO 8601 calendar. Early drafts of the proposal also had versions that took a calendar argument. Those were removed, so if you need another calendar you call withCalendar() on the result.
Exact Time Versus Wall-Clock Time
Temporal.Now.instant() is the only function that ignores time zones. It returns the exact moment as nanoseconds since the Unix epoch. Every machine running at the same moment gets the same value, wherever it is. Use it for timestamps, log entries, and anything you store or send between systems.
All the other functions turn that exact moment into wall-clock fields. To do that they need a time zone. If you pass none, they use the host's current time zone, which Temporal.Now.timeZoneId() reports.
import { Temporal as TemporalPolyfill } from '@js-temporal/polyfill';
const Temporal = globalThis.Temporal ?? TemporalPolyfill;
console.log(Temporal.Now.instant().toString());
// e.g. '2026-11-25T11:26:28.655123456Z'
console.log(Temporal.Now.timeZoneId());
// e.g. 'Europe/London'
console.log(Temporal.Now.zonedDateTimeISO().toString());
// e.g. '2026-11-25T11:26:28.655123456+00:00[Europe/London]'
console.log(Temporal.Now.plainDateISO().toString()); // e.g. '2026-11-25'
console.log(Temporal.Now.plainTimeISO().toString()); // e.g. '11:26:28.655123456'Passing an Explicit Time Zone
Every wall-clock function accepts a time zone as an IANA identifier such as 'Asia/Tokyo', or as a fixed offset such as '+05:30'. You can also pass a ZonedDateTime, and its time zone is used. An unknown identifier throws a RangeError.
import { Temporal as TemporalPolyfill } from '@js-temporal/polyfill';
const Temporal = globalThis.Temporal ?? TemporalPolyfill;
const tokyoToday = Temporal.Now.plainDateISO('Asia/Tokyo');
const laToday = Temporal.Now.plainDateISO('America/Los_Angeles');
// Near midnight UTC these differ by a day
console.log(tokyoToday.toString(), laToday.toString());
try {
Temporal.Now.plainDateISO('Mars/Olympus_Mons');
} catch (e) {
console.log(e instanceof RangeError); // true
}Common Mistakes
Reading the clock more than once
Each call reads the clock again. If you call plainDateISO() and then plainTimeISO() separately, the two calls can land on either side of midnight. The result is a date and a time that never existed together. Read the clock once and derive the other values from that result:
import { Temporal as TemporalPolyfill } from '@js-temporal/polyfill';
const Temporal = globalThis.Temporal ?? TemporalPolyfill;
const now = Temporal.Now.zonedDateTimeISO('Europe/Berlin');
const date = now.toPlainDate();
const time = now.toPlainTime();
console.log(date.toString(), time.toString()); // always consistentUsing Temporal.Now to time code
Temporal.Now.instant() follows the system clock. NTP sync or a manual change can move that clock backward or forward. If you measure elapsed time by subtracting two instants, a clock adjustment can give you a negative or inflated result. For benchmarks and timeouts, use performance.now(), which only ever increases.
Expecting nanosecond precision
Instant stores nanoseconds, but the host decides how precise the clock reading actually is. Browsers deliberately make clock readings less precise to block timing attacks and fingerprinting, so the last digits are often zeros or slightly random. Do not rely on two consecutive calls returning different values.
Hard-coding the clock in logic
A function that calls Temporal.Now inside its body is hard to test, because its result changes every day. Pass the current value in as a parameter, or pass a clock function with a default:
import { Temporal as TemporalPolyfill } from '@js-temporal/polyfill';
const Temporal = globalThis.Temporal ?? TemporalPolyfill;
function isOverdue(dueDate, today = Temporal.Now.plainDateISO()) {
return Temporal.PlainDate.compare(today, dueDate) > 0;
}
const due = Temporal.PlainDate.from('2024-03-15');
// Production: uses the real clock
console.log(isOverdue(due));
// Test: fixed, repeatable date
console.log(isOverdue(due, Temporal.PlainDate.from('2024-03-16'))); // true
console.log(isOverdue(due, Temporal.PlainDate.from('2024-03-15'))); // falseTemporal.PlainDate.compare returns -1, 0, or 1. The comparison chapter covers it in detail.
Choosing the Right Function
- Recording when something happened:
instant(). - Showing the current time to a user, or doing arithmetic that must respect daylight saving:
zonedDateTimeISO(userZone). - Checking "is it this user's birthday today?":
plainDateISO(userZone). - Checking whether a shop in a known zone is open right now:
plainTimeISO(shopZone).
plainDateTimeISO() is the one to use least often. It drops the time zone, so you cannot safely do arithmetic with it across daylight saving changes or turn it back into an exact moment without guessing.
Exercise
A scheduling service runs in a container with TZ=UTC. It computes "today" with Temporal.Now.plainDateISO() and reads the hour with a separate call to Temporal.Now.plainTimeISO(). Users in Sydney say their reminders sometimes show the wrong date. Name the two bugs and rewrite the code that gets the current date and hour for a user whose zone is stored in userZone.
Show answer
The first bug is the missing time zone argument. Both calls use the container's UTC zone instead of the user's, and Sydney is 10 or 11 hours ahead of UTC. The second bug is the pair of separate clock reads, which can land on opposite sides of midnight. The fix reads the clock once in the user's zone: const now = Temporal.Now.zonedDateTimeISO(userZone); const today = now.toPlainDate(); const hour = now.hour;
Exercise
Why should you not subtract two Temporal.Now.instant() values to measure how long a function takes, and what should you use instead?
Show answer
Instant follows the system clock. Clock adjustments such as NTP corrections can move that clock, so the difference can come out negative or wrong. Browsers may also make clock readings less precise. Use performance.now(), which only ever increases and is built for measuring elapsed time.