Firefox Tomorrow

javascript class

Temporal.PlainTime

View on MDN ↗

The Temporal.PlainTime object represents a time without a date or time zone; for example, a recurring event that happens at the same time every day. It is fundamentally represented as a combination of hour, minute, second, millisecond, microsecond, and nanosecond values.

Description

A PlainTime is essentially the time part of a PlainDateTime object, with the date information removed. Because the date and time information don’t have much interaction, all general information about time properties is documented here.

RFC 9557 format

PlainTime objects can be serialized and parsed using the RFC 9557 format, an extension to the ISO 8601 / RFC 3339 format. The string has the following form:

HH:mm:ss.sssssssss
  • HH
    • : A two-digit number from 00 to 23. It may be prefixed by the time designator T or t.
  • mm Optional
    • : A two-digit number from 00 to 59. Defaults to 00.
  • ss.sssssssss Optional
    • : A two-digit number from 00 to 59. May optionally be followed by a . or , and one to nine digits. Defaults to 00. The HH, mm, and ss components can be separated by : or nothing. You can omit either just ss or both ss and mm, so the time can be one of three forms: HH, HH:mm, or HH:mm:ss.sssssssss.

As an input, you may optionally include the date, offset, time zone identifier, and calendar, in the same format as PlainDateTime, but they will be ignored. A date-only string will be rejected. Other annotations in the [key=value] format are also ignored, and they must not have the critical flag.

When serializing, you can configure the fractional second digits.

Constructor

  • Temporal.PlainTime()
    • : Creates a new Temporal.PlainTime object by directly supplying the underlying data.

Static methods

  • Temporal.PlainTime.compare()
    • : Returns a number (-1, 0, or 1) indicating whether the first time comes before, is the same as, or comes after the second time. Equivalent to comparing the hour, minute, second, millisecond, microsecond, and nanosecond fields one by one.
  • Temporal.PlainTime.from()
    • : Creates a new Temporal.PlainTime object from another Temporal.PlainTime object, an object with time properties, or an RFC 9557 string.

Instance properties

These properties are defined on Temporal.PlainTime.prototype and shared by all Temporal.PlainTime instances.

Instance methods

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also