Temporal.ZonedDateTime.prototype.withCalendar()

Limited availability

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

The withCalendar() method of Temporal.ZonedDateTime instances returns a new Temporal.ZonedDateTime object representing this date-time interpreted in the new calendar system. Because all Temporal objects are designed to be immutable, this method essentially functions as the setter for the date-time's calendarId property.

To replace the date-time component properties, use the with() method. To replace its time zone, use the withTimeZone() method.

Syntax

js
withCalendar(calendar)

Parameters

calendar

A string that corresponds to the calendarId property. See Intl.supportedValuesOf() for a list of commonly supported calendar types.

Return value

A new Temporal.ZonedDateTime object, representing the date-time specified by the original ZonedDateTime, interpreted in the new calendar system.

Exceptions

TypeError

Thrown if calendar is not a string.

RangeError

Thrown if calendar is not a valid calendar identifier.

Examples

Using withCalendar()

js
const zdt = Temporal.ZonedDateTime.from(
  "2021-07-01T12:34:56[America/New_York]",
);
const newZDT = zdt.withCalendar("islamic-umalqura");
console.log(newZDT.toLocaleString("en-US", { calendar: "islamic-umalqura" }));
// 11/21/1442 AH, 12:34:56 PM EDT

Specifications

Specification
Temporal
# sec-temporal.zoneddatetime.prototype.withcalendar

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
withCalendar
Chrome – Full support
Chrome 144 (Release date: 2026-01-13)
footnote Full support
Edge – Full support
Edge 144 (Release date: 2026-01-21)
footnote Full support
Firefox – Partial support
Firefox 139 (Release date: 2025-05-27)
footnote Partial support
footnote Calendars islamic, islamic-rgsa and islamic-umalqura are not available. See bug 1950425 and bug 1954138.
Opera – Full support
Opera 128 (Release date: 2026-02-26)
footnote Full support
Safari – No support
Safari
footnote
footnote See bug 223166
Chrome Android – Full support
Chrome Android 144 (Release date: 2026-01-13)
footnote Full support
Firefox for Android – Partial support
Firefox for Android 139 (Release date: 2025-05-27)
footnote Partial support
footnote Calendars islamic, islamic-rgsa and islamic-umalqura are not available. See bug 1950425 and bug 1954138.
Opera Android – Full support
Opera Android 95 (Release date: 2026-02-11)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 223166
Samsung Internet – No support
Samsung Internet
footnote No support
WebView Android – Full support
WebView Android 144 (Release date: 2026-01-13)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote
footnote See bug 223166
Bun – No support
Bun
footnote No support
Deno – Full support
Deno 2.7 (Release date: 2026-02-25)
footnote Full support
Node.js – No support
Node.js
footnote No support

Legend

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

Full support
Full support
Partial support
Partial support
No support
No support
See implementation notes.

See also