Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST

Basic JavaScript

JS Tutorial JS Syntax JS Variables JS Operators JS If Conditions JS Loops JS Strings JS Numbers JS Functions JS Objects JS Scope JS Dates JS Temporal  New JS Arrays JS Sets JS Maps JS Iterations JS Math JS RegExp JS Destructuring JS Data Types JS Errors JS Debugging JS Conventions JS References JS 2026 JS Versions

JS HTML

JS HTML DOM JS Events JS Projects New

JS Advanced

JS Functions JS Objects JS Classes JS Asynchronous JS Modules JS Meta & Proxy JS Typed Arrays JS DOM Navigation JS Windows JS Web APIs JS AJAX JS JSON JS jQuery JS Graphics JS Examples JS Reference


JS Temporal Reference


Temporal Objects

Temporal objects are the core part of the Temporal API which aims to replace the old Date object.

ObjectDescription
Temporal.DurationLength of time (e.g days, hours, minutes)
Temporal.NowThe current time
Temporal.InstantA fixed point in time, independent of time zone
Temporal.ZonedDateTimeDate and time in a specific time zone
Plain Dates
Temporal.PlainDate()Calendar date only (2026-05-17)
Temporal.PlainTime()Time of day only (14:30:00)
Temporal.PlainDateTime()Full date and time (2026-05-17 14:30:00)
Temporal.PlainYearMonth()Year and month only (2026-05)
Temporal.PlainMonthDay()Month and day only (05-01)
Temporal Map

Note

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


Temporal.Duration Methods

MethodDescription
compare()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()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

PropertyDescription
blankBoolean true if the duration represents a zero duration
daysDays as an integer (1-31)
hoursHours as an integer (0-23
microsecondsMicroseconds as an integer (0-999)
millisecondsMilliseconds as an integer (0-999)
minutesMinutes as an integer (0-59)
monthsMonths as an integer (1-12)
nanosecondsNanoseconds as an integer (0-999)
secondsSeconds as an integer (0-59)
sign1 positive -1 negative
weeksWeeks as an integer
yearsYears as an integer

Temporal.Now Methods

MethodDescription
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
newCreates 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()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()Returns the duration until another date
Converting
toZonedDateTimeISO()Returns a new ZonedDatetime object
Formatting
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the instant
toString()Returns an RFC 9557 format string representation of the instant
valueOf()Throws a TypeError (Instants should not be converted to a primitives)

Temporal ZonedDateTime Methods

MethodDescription
from()Returns a new ZonedDateTime object from an object or a string
getTimeZone
Transition()
Returns a ZonedDateTime object representing the closest instant after or before this instant
startOfDay()Returns a ZonedDateTime object representing the first instant of this date
toInstant()Returns a new Instant object representing this date-time
toPlainDate()Returns a new PlainDate object representing this date-time
toPlainDateTime()Returns a new PlainDateTime object representing this date-time
toPlainTime()Returns a new PlainTime object representing this date-time
with()Returns a new ZonedDateTime with specified fields modified
withCalendar()Returns a new ZonedDateTime with a different calendar system
withPlainTime()Returns a new ZonedDateTime the time part replaced by a new time
withTimeZone()Returns a new ZonedDateTime object representing this date-time in the new time zone
Arithmetic
add()Returns a new ZonedDateTime with a duration added
subtract()Returns a new ZonedDateTime with a duration subtracted
round()Returns a new ZonedDateTime rounded to a given unit
Comparison
compare()Returns -1, 0, or 1 from comparing two dates
equals()Returns true if two ZonedDateTime objects are identical
since()Returns the difference from another date
until()Returns the difference until another date
Formatting
toString()Returns an ISO 8601 string representation
toJSON()Returns an ISO 8601 string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the date
valueOf()Throws a TypeError (prevents temporals from being converted to primitives)

Temporal ZonedDateTime Properties

PropertyDescription
calendarIDCalendar system identifier ("iso8601")
dayThe day as an integer (1-31)
dayOfWeekThe day of the week as an integer (1 = Monday)
dayOfYearThe ordinal day of the year
daysInMonthThe total number of days in that month
daysInWeekThe total number of days in that week
daysInYearThe total number of days in that year
epochMillisecondsNumber of milliseconds since Unix epoch
epochNanosecondsNumber of nanoseconds since Unix epoch
eraThe era name of the calendar, if applicable ("gregory")
eraYearThe year within the era, if applicable
hourThe hour as an integer (0-23)
hoursInDayHours in this day in this time zone(0-25)
inLeapYearA boolean indicating if the date falls in a leap year
microsecondThe microsecond as an integer (0-999)
millisecondThe millisecond as an integer (0-999)
minuteThe minute as an integer (0-59)
monthThe month as an integer (1-12)
monthCodeA calendar-specific string code for the month ("M01")
monthsInYearThe total number of months in that year
nanosecondThe nanosecond as an integer (0-999)
offsetOffset used to interpret this instant (+HH:mm:ss.sssssssss)
offsetNanosecondsOffset used to interpret this instant in nanoseconds
secondThe second as an integer (0-59)
timeZoneIdTime zone identifier used to interpret this instant
weekOfYearThe week number within the year
yearThe year as an integer
yearOfWeekThe year that the week belongs to

Display All Properties

const zoned = Temporal.ZonedDateTime.from("2026-05-17T14:30:00[Europe/Oslo]");
Try it Yourself »

Temporal Plain Objects

ObjectDescription
Temporal.PlainDateCalendar date only (2026-05-21)
Temporal.PlainTimeTime of day only (14:30:00)
Temporal.PlainMonthDayMonth and day only (05-01)
Temporal.PlainYearMonthYear and month only (2026-05)

Temporal.PlainDate Methods

ConstructingDescription
from()Creates a new PlainDate object from an object or a string
newCreates a new PlainDate object from (year, month, day)
Arithmetic
add()Returns a new PlainDate with a duration added
subtract()Returns a new PlainDate with a duration subtracted
Comparing
compare()Returns -1, 0, or 1 from comparing two dates
equals()Returns true if two PlainDate objects are identical
since()Returns the difference since another date
until()Returns the difference until another date
Converting
toPlainDateTime()Returns a new PlainDateTime object
toPlainMonthDay()Returns a new PlainMonthDay object
toPlainYearMonth()Returns a new PlainYearMonth object
toZonedDateTime()Returns a new ZonedDatetime object
with()Returns a new PlainDate with specified fields modified
withCalendar()Returns a new PlainDate with a different calendar system
Formatting
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the date
toString()Returns an RFC 9557 format string representation
valueOf()Throws a TypeError (should not be converted to primitives)

Temporal.PlainDate Properties

PropertyDescription
calendarIDCalendar system identifier ("iso8601")
dayThe day as an integer (1-31)
dayOfWeekThe day of the week as an integer (1 = Monday)
dayOfYearThe ordinal day of the year
daysInMonthThe total number of days in that month
daysInWeekThe total number of days in that week
daysInYearThe total number of days in that year
eraThe era name of the calendar, if applicable
eraYearThe year within the era, if applicable
inLeapYearA boolean indicating if the year is a leap year
monthThe month as an integer (1-12)
monthCodeA string code for the month ("M01")
monthsInYearThe total number of months in that year
weekOfYearThe week number within the year
yearThe year as an integer
yearOfWeekThe year that the week belongs to

Display All Properties

const date = new Temporal.PlainDate(2026, 5, 17);
Try it Yourself »

Temporal.PlainYearMonth Methods

MethodDescription
from()Returns a new PlainDate object from another object or a string
toPlainDate()Returns a new PlainDate object
with()Returns a new PlainDate with specified fields modified
Arithmetic
add()Returns a new PlainDate with a duration added
subtract()Returns a new PlainDate with a duration subtracted
Comparison
compare()Returns -1, 0, or 1 from comparing two dates
equals()Returns true if two PlainDate objects are identical
since()Returns the difference since another date
until()Returns the difference until another date
Formatting
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the date
toString()Returns an RFC 9557 format string representation
valueOf()Throws a TypeError (prevents temporals from being converted to primitives)

Temporal.PlainYearMonth Properties

PropertyDescription
calendarIDCalendar system identifier ("iso8601")
daysInMonthThe total number of days in that month
daysInYearThe total number of days in that year
eraThe era name of the calendar, if applicable ("gregory")
eraYearThe year within the era, if applicable
inLeapYearA boolean indicating if the date falls in a leap year
monthThe month as an integer (1-12)
monthCodeA calendar-specific string code for the month ("M01")
monthsInYearThe total number of months in that year
yearThe year as an integer

Temporal.PlainMonthDay Methods

MethodDescription
equals()Returns true if two PlainDate objects are identical
from()Returns a new PlainDate object from another object or a string
toPlainDate()Returns a new PlainDate object
with()Returns a new PlainDate with specified fields modified
withCalendar()Returns a new PlainDate with a different calendar system
Formatting
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the date
toString()Returns an RFC 9557 format string representation
valueOf()Throws a TypeError (prevents temporals from being converted to primitives)

Temporal.PlainMonthDay Properties

PropertyDescription
calendarIDCalendar system identifier ("iso8601")
dayThe day as an integer (1-31)
monthCodeA calendar-specific string code for the month ("M01")


Temporal PlainTime Methods

ConstructingDescription
from()Returns a new PlainTime object from another object or a string
Arithmetic
add()Returns a new PlainTime with a duration added
subtract()Returns a new PlainTime with a duration subtracted
round()Returns a new PlainTime rounded to a given unit
Comparing
compare()Returns -1, 0, or 1 from comparing two times
equals()Returns true if two PlainTime objects are identical
since()Returns the difference since another time
until()Returns the difference until another time
Converting
with()Returns a new PlainTime with specified fields modified
Formatting
toString()Returns an RFC 9557 format string representation
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString()Returns a language-sensitive representation of the time
valueOf()Throws a TypeError (prevents temporals from being converted to primitives)

Temporal.PlainTime Properties

PropertyDescription
hourThe hour as an integer (0-23
microsecondThe microsecond as an integer (0-999)
millisecondThe millisecond as an integer (0-999)
minuteThe minute as an integer (0-59)
nanosecondThe nanosecond as an integer (0-999)
secondThe second as an integer (0-59)

Temporal.PlainDateTime Methods

ConstructingDescription
from() Creates a PlainDateTime object from an object or a string
new Creates a PlainDateTime object from parameters
Arithmetic
add() Returns a PlainDateTime with a duration added
subtract() Returns a PlainDateTime with a duration subtracted
round() Returns a PlainDateTime rounded to a given unit
Comparing
compare() Returns -1, 0, or 1 from comparing two dates
equals() Returns true if two PlainDateTime objects are identical
since() Returns the difference from another PlainDateTime
until() Returns the difference until another PlainDateTime
Converting
toPlainDate() Returns a PlainDate object with the date from this PlainDateTime
toPlainTime() Returns a PlainTime object with the time from this PlainDateTime
toZonedDateTime() Returns a ZonedDatetime object with this PlainDateTime in a time zone
with() Returns a PlainDateTime with specified fields modified
withCalendar() Returns a PlainDateTime with a different calendar system
withPlainTime() Returns a PlainDateTime with the time part replaced by a new time
Formatting
toJSON()Returns an RFC 9557 format string for JSON serialization
toLocaleString() Returns a language-sensitive representation of the date
toString() Returns an RFC 9557 format string representation of the date
valueOf() Throws an error to prevents temporals from being converted to primitives

Temporal.PlainDateTime Properties

PropertyDescription
calendarIDCalendar system identifier ("iso8601")
dayThe day as an integer (1-31)
dayOfWeekThe day of the week as an integer (1 = Monday)
dayOfYearThe ordinal day of the year
daysInMonthThe total number of days in that month
daysInWeekThe total number of days in that week
daysInYearThe total number of days in that year
eraThe era name of the calendar, if applicable ("gregory")
eraYearThe year within the era, if applicable
hourThe hour as an integer (0-23
inLeapYearA boolean indicating if the date falls in a leap year
microsecondThe microsecond as an integer (0-999)
millisecondThe millisecond as an integer (0-999)
minuteThe minute as an integer (0-59)
monthThe month as an integer (1-12)
monthCodeA calendar-specific string code for the month ("M01")
monthsInYearThe total number of months in that year
nanosecondThe nanosecond as an integer (0-999)
secondThe second as an integer (0-59)
weekOfYearThe week number within the year
yearThe year as an integer
yearOfWeekThe year that the week belongs to

Display All Properties

const date = new Temporal.PlainDateTime(2026, 5, 1, 14, 30);
Try it Yourself »

Temporal Arithmetic

MethodReturns
temporal.add() New temporal representing a date moved forward by a duration
temporal.subtract() New temporal representing a date moved backward by a duration
temporal.round() New temporal rounded down to specified unit

Temporal Comparison

MethodDescription
temporal.compare() Static method useful for sorting arrays of dates (returns -1, 0, or 1)
temporal.equals() Returns true if two dates (and their calendars) are identical
temporal.since() The duration between two temporal objects
temporal.until() The duration between two temporal objects


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.

-->