Temporal.Now.zonedDateTimeISO()

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.Now.zonedDateTimeISO() static method returns the current date and time as a Temporal.ZonedDateTime object, in the ISO 8601 calendar and the specified time zone.

Syntax

js
Temporal.Now.zonedDateTimeISO()
Temporal.Now.zonedDateTimeISO(timeZone)

Parameters

timeZone Optional

Either a string or a Temporal.ZonedDateTime instance representing the time zone to interpret the system time in. 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

The current date and time in the specified time zone, as a Temporal.ZonedDateTime object using the ISO 8601 calendar. Has the same precision as Temporal.Now.instant().

Exceptions

RangeError

Thrown if the time zone is invalid.

Examples

Using Temporal.Now.zonedDateTimeISO()

js
// The current date and time in the system's time zone
const dateTime = Temporal.Now.zonedDateTimeISO();
console.log(dateTime); // e.g.: 2021-10-01T06:12:34.567890123+03:00[Africa/Nairobi]

// The current date and time in the "America/New_York" time zone
const dateTimeInNewYork = Temporal.Now.zonedDateTimeISO("America/New_York");
console.log(dateTimeInNewYork); // e.g.: 2021-09-30T23:12:34.567890123-04:00[America/New_York]

Specifications

Specification
Temporal proposal
# sec-temporal.now.zoneddatetimeiso

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
zonedDateTimeISO
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