The toPlainTime() method of Temporal.PlainDateTime instances returns a new Temporal.PlainTime object representing the time part (hour, minute, second, and subsecond components) of this date-time.
Syntax
toPlainTime()
Parameters
None.
Return value
A new Temporal.PlainTime object representing the time part (hour, minute, second, and subsecond components) of this date-time.
Examples
Using toPlainTime()
const dt = Temporal.PlainDateTime.from("2021-07-01T12:34:56");
const time = dt.toPlainTime();
console.log(time.toString()); // '12:34:56'
Specifications
Browser compatibility
See also
- Temporal.PlainDateTime
- Temporal.PlainTime
- Temporal/PlainDateTime/toPlainDate
- Temporal/PlainDateTime/toZonedDateTime
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
