bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/JavaScript/Objects, Classes, and Advanced Patterns
JavaScript•Objects, Classes, and Advanced Patterns

JS Temporal Reference

Concept visual

JS Temporal Reference

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Temporal Objects

Temporal objects are the core part of the

Temporal API

which aims to replace the old Date object.

Object

Description

Temporal.Duration Length of time (e.g days, hours, minutes) Temporal.Now

The current time

Temporal.Instant A fixed point in time, independent of time zone Temporal.ZonedDateTime Date and time in a specific time zone

Plain Dates

Temporal.PlainDate()

Formula

Calendar date only (2026 - 05 - 17)

Temporal.PlainTime() Time of day only (14:30:00) Temporal.PlainDateTime()

Formula

Full date and time (2026 - 05 - 17 14:30:00)

Temporal.PlainYearMonth()

Formula

Year and month only (2026 - 05)

Temporal.PlainMonthDay()

Formula

Month and day only (05 - 01)

All Temporal objects are immutable, which helps prevent bugs related to accidental modification of time values. Temporal.Duration Methods

Method

Description compare()

Formula

Comparing two durations (returning - 1, 0, or 1)

from() Returns a new duration from an object or an ISO string with() Returns a new duration with specified field(s) modified

Arithmetic abs()

Returns a new duration with the absolute value of this duration add() Returns a new duration with a duration added to this duration negated() Returns a new duration with this duration negated round() Returns a new duration with this duration rounded subtract() Returns a new duration with a duration subtracted from this duration

Formatting total()

Returns a number representing the duration in a given unit toJSON() Returns an RFC 9557 format string for JSON serialization toLocaleString()

Formula

Returns a language - sensitive representation of the time toString()

Returns an RFC 9557 format string representation valueOf() Throws a TypeError (prevents temporals from being converted to primitives) Temporal.Duration Properties

Property

Description blank

Boolean true if the duration represents a zero duration days

Formula

Days as an integer (1 - 31)

hours

Formula

Hours as an integer (0 - 23 microseconds
Microseconds as an integer (0 - 999)

milliseconds

Formula

Milliseconds as an integer (0 - 999)

minutes

Formula

Minutes as an integer (0 - 59)

months

Formula

Months as an integer (1 - 12)

nanoseconds

Formula

Nanoseconds as an integer (0 - 999)

seconds

Formula

Seconds as an integer (0 - 59)

sign

Formula

1 positive - 1 negative weeks

Weeks as an integer years

Years as an integer

Learn More:

Temporal Duration Tutorial

Temporal.Now Methods

Method

Description instant()

Returns current time as a Temporal.Instant object plainDateISO() Returns current date as a Temporal.PlainDate object plainDateTimeISO() Returns current date and time as a Temporal.PlainDateTime object plainTimeISO() Returns current time as a Temporal.PlainTime object timeZoneId Returns system's time zone as a time zone id zonedDateTimeISO() Returns current date and time as a Temporal.ZonedDateTime object

Learn More:

Temporal Now Tutorial

Temporal.Instant Methods

Constructing new

Creates a new Temporal.Instant object from() Creates a new Instant object from another instant or a string fromEpochMilliseconds() Returns a new Instant object from a number of milliseconds fromEpochNanoseconds() Returns a new Instant object from a number of nanoseconds

Arithmetic add()

Returns a new Instant with a duration added round() Returns a new Instant with this instant rounded subtract() Returns a new Instant with a duration subtracted

Comparing compare()

Formula

Returns - 1, 0, or 1 from comparing two instants equals()

Returns true if two instants are identical since()

Returns the duration since another date until()

Previous

JavaScript Object Protection

Next

JavaScript Object Prototypes