Temporal.ZonedDateTime.prototype.until()

Limited availability

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

The until() method of Temporal.ZonedDateTime instances returns a new Temporal.Duration object representing the duration from this date-time to another date-time (in a form convertible by Temporal.ZonedDateTime.from()). The duration is positive if the other date-time is after this date-time, and negative if before.

This method does other - this. To do this - other, use the since() method.

Syntax

js
until(other)
until(other, options)

Parameters

other

A string, an object, or a Temporal.ZonedDateTime instance representing a date-time to subtract this date-time from. It is converted to a Temporal.ZonedDateTime object using the same algorithm as Temporal.ZonedDateTime.from(). It must have the same calendar as this.

options Optional

The same options as since().

Return value

A new Temporal.Duration object representing the duration from this date-time until other. The duration is positive if other is after this date-time, and negative if before.

Exceptions

RangeError

Thrown in one of the following cases:

  • other has a different calendar than this.
  • Any of the options is invalid.
  • other has a different time zone than this, and largestUnit is "days" or above.

Examples

Using until()

js
const flight = Temporal.ZonedDateTime.from(
  "2024-12-21T13:31:00-05:00[America/New_York]",
);
const now = Temporal.Now.zonedDateTimeISO("America/New_York").round("second");
if (Temporal.ZonedDateTime.compare(flight, now) < 0) {
  console.error(
    "The flight is already in the past. The result may not make sense.",
  );
}
const duration = now.until(flight, { largestUnit: "days" });
console.log(`The flight is in ${duration.toLocaleString("en-US")}`);

For more examples, see since().

Specifications

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

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
until
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 – Full support
Firefox 139 (Release date: 2025-05-27)
footnote Full support
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 – Full support
Firefox for Android 139 (Release date: 2025-05-27)
footnote Full support
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
No support
No support
See implementation notes.

See also