Temporal.PlainDateTime()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The Temporal.PlainDateTime() constructor creates Temporal.PlainDateTime objects.

This constructor allows you to create instances by directly supplying the underlying data. Like all other Temporal classes, you should usually construct Temporal.PlainDateTime objects using the Temporal.PlainDateTime.from() static method, which can handle a variety of input types.

Syntax

js
new Temporal.PlainDateTime(year, month, day)
new Temporal.PlainDateTime(year, month, day, hour)
new Temporal.PlainDateTime(year, month, day, hour, minute)
new Temporal.PlainDateTime(year, month, day, hour, minute, second)
new Temporal.PlainDateTime(year, month, day, hour, minute, second, millisecond)
new Temporal.PlainDateTime(year, month, day, hour, minute, second, millisecond, microsecond)
new Temporal.PlainDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond)
new Temporal.PlainDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, calendar)

Note: Temporal.PlainDateTime() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters

year

A number, truncated to an integer, representing the year in the ISO calendar system.

month

A number, truncated to an integer, representing the month in the ISO calendar system.

day

A number, truncated to an integer, representing the day of the month in the ISO calendar system.

hour Optional

A number, truncated to an integer, representing the hour component.

minute Optional

A number, truncated to an integer, representing the minute component.

second Optional

A number, truncated to an integer, representing the second component.

millisecond Optional

A number, truncated to an integer, representing the millisecond component.

microsecond Optional

A number, truncated to an integer, representing the microsecond component.

nanosecond Optional

A number, truncated to an integer, representing the nanosecond component.

calendar Optional

A string representing the calendar to use. See Intl.supportedValuesOf() for a list of commonly supported calendar types. Defaults to "iso8601". Note that irrespective of the calendar, the year, month, and day must be in the ISO 8601 calendar system.

Return value

A new Temporal.PlainDateTime object, representing the date-time specified by the parameters.

Exceptions

RangeError

Thrown in one of the following cases:

  • Any date-time component is not a finite number.
  • The date-time component combination does not represent a valid date in the ISO calendar system, or is not in the representable range, which is ±(108 + 1) days, or about ±273,972.6 years, from the Unix epoch.
  • calendar is not a valid calendar identifier.

Examples

Using Temporal.PlainDateTime()

js
const dt = new Temporal.PlainDateTime(2021, 7, 1);
console.log(dt.toString()); // 2021-07-01T00:00:00

const dt2 = new Temporal.PlainDateTime(2021, 7, 1, 0, 0, 0, 0, 0, 0, "hebrew");
console.log(dt2.toString()); // 2021-07-01T00:00:00[u-ca=hebrew]

Specifications

Specification
Temporal
# sec-temporal-plaindatetime-constructor

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
PlainDateTime() constructor
Experimental
Chrome – No support
Chrome
footnote
footnote See bug 401065166
Edge – No support
Edge
footnote
footnote See bug 401065166
Firefox – Full support
Firefox 139 (Release date: 2025-05-27)
footnote Full support
Opera – No support
Opera
footnote
footnote See bug 401065166
Safari – No support
Safari
footnote
footnote See bug 223166
Chrome Android – No support
Chrome Android
footnote
footnote See bug 401065166
Firefox for Android – Full support
Firefox for Android 139 (Release date: 2025-05-27)
footnote Full support
Opera Android – No support
Opera Android
footnote
footnote See bug 401065166
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 223166
Samsung Internet – No support
Samsung Internet
footnote
footnote See bug 401065166
WebView Android – No support
WebView Android
footnote
footnote See bug 401065166
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 223166
Bun – No support
Bun
footnote No support
Deno – Full support
Deno 2.7 (Release date: 2026-02-25)
footnote Full support
Node.js – No support
Node.js
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

See also