Loading lesson path
Concept visual
Start at both ends
Temporal objects are the core part of the
which aims to replace the old Date object.
Temporal.Duration Length of time (e.g days, hours, minutes) Temporal.Now
Temporal.Instant A fixed point in time, independent of time zone Temporal.ZonedDateTime Date and time in a specific time zone
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
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
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
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
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 weeksTemporal.Now Methods
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
Temporal.Instant Methods
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
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
Formula
Returns - 1, 0, or 1 from comparing two instants equals()Returns true if two instants are identical since()