大网数据广告活动
Web 标准与前端开发

Temporal.PlainDate.prototype.toPlainDateTime()

· 52CE 我爱测

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.

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

  • plainTime
    • : A string, an object, or a Temporal.PlainTime instance representing the time component of the resulting PlainDateTime. It is converted to a Temporal.PlainTime object using the same algorithm as Temporal/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

See also

  • Temporal.PlainDate
  • Temporal.PlainDateTime
  • Temporal.PlainTime
  • Temporal/PlainDate/toPlainMonthDay
  • Temporal/PlainDate/toPlainYearMonth
  • Temporal/PlainDate/toZonedDateTime
  • Temporal/PlainDateTime/toPlainDate

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。