Getting the Current Time with Temporal.Now
How to read the current instant, wall-clock time, and civil date with Temporal.Now, and why new Date() gives the wrong day off-box. Part of Modern Temporal API.
Problem framing
"Now" is not a single value — it is an instant, and separately a set of wall-clock fields that only exist once you name a time zone. Legacy new Date() blurs the two: it captures the instant but exposes it through the host machine's zone, so the same code reports a different calendar day on a server in Los Angeles and a browser in Tokyo. Temporal.Now splits the concept into precise methods, forcing you to say whether you want the absolute instant or the current wall-clock reading in a named zone.
API reference
Temporal.Now is a namespace of read-only clocks. Each returns the current moment as a different type.
Approach A: legacy Date
Legacy code reads the clock with Date.now() (epoch ms) or new Date() (an instant viewed through the host zone). There is no way to ask for "today in Tokyo" without constructing a formatter.
const nowMs = Date.now(); // absolute, fine
const today = new Date().getDate(); // host-zone day — wrong off-box
Approach B: Temporal.Now
Name the zone and Temporal returns the correct wall-clock present.
import { Temporal } from '@js-temporal/polyfill';
const instant = Temporal.Now.instant(); // absolute
const tokyoNow = Temporal.Now.zonedDateTimeISO('Asia/Tokyo'); // wall clock in Tokyo
const tokyoToday = Temporal.Now.plainDateISO('Asia/Tokyo'); // civil date in Tokyo
Production implementation
Inject the clock so code is testable rather than reading Temporal.Now directly everywhere.
import { Temporal } from '@js-temporal/polyfill';
export interface Clock { now(): Temporal.Instant; today(tz: string): Temporal.PlainDate; }
export const systemClock: Clock = {
now: () => Temporal.Now.instant(),
today: (tz) => Temporal.Now.plainDateISO(tz),
};
// Pass a fixed Clock in tests for deterministic results.
Edge cases
Gotchas & common pitfalls
Testing checklist
Frequently Asked Questions
How do I get the current date in a specific time zone with Temporal?
Call Temporal.Now.plainDateISO(timeZone) with an IANA id such as 'Asia/Tokyo'. It returns today's civil date in that zone, which can differ from the server's date, so it is the reliable way to compute 'today' for a user in another region.
Is Temporal.Now.instant() suitable for measuring elapsed time?
No. Like Date.now() it reads the wall clock, which can jump when the system time is adjusted. For measuring durations use performance.now(), which is monotonic; use Temporal.Now.instant() for timestamps that represent an actual moment.
How do I make code that reads the current time testable?
Wrap Temporal.Now behind a small Clock interface and inject it. Production wires the system clock; tests pass a clock that returns a fixed instant, so time-dependent logic becomes deterministic without monkey-patching globals.