MDN self-hosted library · e01.org

Temporal.PlainDateTime.prototype.toPlainTime()

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.

Open notebook · 1 cells javascript-instance-method upstream source

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.prototype.toPlainDate()
  • Temporal.PlainDateTime.prototype.toZonedDateTime()