Temporal.Instant.from()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The Temporal.Instant.from() static method creates a new Temporal.Instant object from another Temporal.Instant object, or an RFC 9557 string.

Syntax

Parameters

info

One of the following:

  • A Temporal.Instant instance, which creates a copy of the instance.
  • An RFC 9557 string containing a date, time, and time zone offset. The time zone name is ignored; only the offset is used.

Return value

A new Temporal.Instant object representing the instant in time specified by info.

Exceptions

TypeError

Thrown if info is not a Temporal.Instant instance or a string.

RangeError

Thrown in one of the following cases:

  • The string is not a valid RFC 9557 string.
  • The info is not in the representable range, which is ±108 days, or about ±273,972.6 years, from the Unix epoch.

Examples

Creating an instant from a string

Creating an instant from another instant

Specifications

Specification
Temporal
# sec-temporal.instant.from

Browser compatibility

See also