Choosing a Temporal Type

The clinic’s closed day, Tuesday 3 November, is a calendar day, and Fiona’s appointment is a moment on that day at eleven in London. Date can’t hold the first without a time, which is how Callum’s laptop came to rebook the wrong patient. Temporal, JavaScript’s modern date and time API, can. It’s a global in Node 26, so there’s nothing to import, and recent browsers have it too, though older runtimes don’t.

Match the Type to What You Know

Temporal follows the same idea as Python’s datetime module, with a type for each kind of value:

Python Temporal
date Temporal.PlainDate
naive time Temporal.PlainTime
naive datetime Temporal.PlainDateTime
aware datetime with a ZoneInfo Temporal.ZonedDateTime
a UTC timestamp Temporal.Instant
timedelta Temporal.Duration
date.fromisoformat("2026-11-03") Temporal.PlainDate.from("2026-11-03")
date(2026, 11, 3) Temporal.PlainDate.from({ year: 2026, month: 11, day: 3 })
.year, .month, .day, .hour .year, .month, .day, .hour
.isoweekday() (Tuesday is 2) .dayOfWeek (Tuesday is 2)
.date() .toPlainDate()

An aware Python time has no direct PlainTime equivalent, since PlainTime stores no zone or offset. A Duration differs from timedelta because it keeps calendar units and distinguishes a day from twenty-four hours. You’ll use that distinction in later lessons.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert JavaScript developers.

Unlock This Lesson

Already a member? Sign-In

Become a Member to join the conversation.