Temporal.PlainDate.prototype.toPlainDateTime()
Baseline Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The toPlainDateTime() method of Temporal.PlainDate instances returns a new Temporal.PlainDateTime object representing this date and a supplied time in the same calendar system.
Syntax
toPlainDateTime() toPlainDateTime(plainTime)
Parameters
-
plainTimeOptional - A string, an object, or a
Temporal.PlainTimeinstance representing the time component of the resultingPlainDateTime. It is converted to aTemporal.PlainTimeobject using the same algorithm asTemporal.PlainTime.from(). Defaults to"00:00:00".
Return value
A new Temporal.PlainDateTime object representing the date and time specified by this date and plainTime, interpreted in the calendar system of this date.
Examples
Using toPlainDateTime()
const date = Temporal.PlainDate.from("2021-07-01");
const dateTime = date.toPlainDateTime("12:34:56");
console.log(dateTime.toString()); // 2021-07-01T12:34:56
const midnight = date.toPlainDateTime();
console.log(midnight.toString()); // 2021-07-01T00:00:00
const date2 = Temporal.PlainDate.from("2021-07-01[u-ca=chinese]");
const dateTime2 = date2.toPlainDateTime("12:34:56");
console.log(dateTime2.toString()); // 2021-07-01T12:34:56[u-ca=chinese]
Specifications
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 | |
toPlainDateTime |
144 |
144 |
139 |
128 |
preview |
144 |
139 |
95 |
No |
No |
144 |
No |
1.4.0 |
2.7 |
26.0.0 |
See also
Temporal.PlainDateTemporal.PlainDateTimeTemporal.PlainTimeTemporal.PlainDate.prototype.toPlainMonthDay()Temporal.PlainDate.prototype.toPlainYearMonth()Temporal.PlainDate.prototype.toZonedDateTime()Temporal.PlainDateTime.prototype.toPlainDate()
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal/PlainDate/toPlainDateTime