Temporal.Instant.prototype.toZonedDateTimeISO()

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 toZonedDateTimeISO() method of Temporal.Instant instances returns a new Temporal.ZonedDateTime object representing this instant in the specified time zone using the ISO 8601 calendar system.

Syntax

js
toZonedDateTimeISO(timeZone)

Parameters

timeZone

Either a string or a Temporal.ZonedDateTime instance representing the time zone to use. If a Temporal.ZonedDateTime instance, its time zone is used. If a string, it can be a named time zone identifier, an offset time zone identifier, or a date-time string containing a time zone identifier or an offset (see time zones and offsets for more information).

Return value

A new Temporal.ZonedDateTime object representing this instant in the specified time zone using the ISO 8601 calendar system.

Exceptions

RangeError

Thrown if the time zone name is invalid.

TypeError

Thrown if timeZone is not a string or a Temporal.ZonedDateTime instance.

Examples

Using toZonedDateTimeISO()

js
const instant = Temporal.Instant.from("2021-08-01T12:34:56.123456789Z");
const zonedDateTime = instant.toZonedDateTimeISO("America/New_York");
console.log(zonedDateTime.toString()); // 2021-08-01T08:34:56.123456789-04:00[America/New_York]

const localDateTime = instant.toZonedDateTimeISO(Temporal.Now.timeZoneId());
console.log(localDateTime.toString()); // This instant in your timezone

Specifications

Specification
Temporal proposal
# sec-temporal.instant.prototype.tozoneddatetimeiso

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
toZonedDateTimeISO
Experimental

Legend

Tip: you can click/tap on a cell for more information.

No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
User must explicitly enable this feature.

See also