Open Playground
JS TutorialLesson #208

JS Temporal Differences

The since() method calculates the since duration between two dates.

JavaScript since() and until()

The since() method calculates the since duration between two dates.

The until() method calculates the until duration between two dates.

The since() and until() are effectivly the inverse of each other.

All temporal date objects have their own since() method:

  • plaindate.since(plaindate)
  • plaintime.since(plaintime)
  • plainyearmonth.since(plainyearmonth)
  • plainmonthday.since(plainmonthday)
  • plaindatetime.since(plaindatetime)
  • zoneddatetime.since(zoneddatetime)
  • instant.since(instant)

All temporal objects have their own until() method:

  • plaindate.until(plaindate)
  • plaintime.until(plaintime)
  • plainyearmonth.until(plainyearmonth)
  • plainmonthday.until(plainmonthday)
  • plaindatetime.until(plaindatetime)
  • zoneddatetime.until(zoneddatetime)
  • instant.until(instant)

JavaScript Temporal since()

The since() method calculates the duration between two temporal dates.

Syntax

Example Code

javascript
Try it Yourself
t1.since(t2, options)

Example

Example Code

javascript
Try it Yourself
const start = Temporal.PlainDate.from("2026-05-01");

const end = Temporal.PlainDate.from("2026-05-17");

const duration = start.since(end);
The since() method returns a Temporal.Duration Object > representing the elapsed time. > The duration is positive if the "other" date is in the past. > The duration is negative if the "other" date is in the future.

JavaScript Temporal until()

The until() method calculates the duration between two temporal dates.

The until() method is effectively the inverse of the since() method. ### Syntax ``javascript t1.until(t2, options) ` ### Example `javascript const start = Temporal.PlainDate.from("2026-05-01"); const end = Temporal.PlainDate.from("2026-05-17"); const duration = start.until(end); `` --- ## Temporal since() vs until() The methods are opposites.

MethodMeaning
a.since(b)time from b → a
a.until(b)time from a → b

Example

Example Code

javascript
Try it Yourself
const start = Temporal.PlainDate.from("2026-05-01");

const end = Temporal.PlainDate.from("2026-05-17");

const duration1 = start.since(end);

const duration2 = start.until(end);

Think:

  • since = past (since yesterday)
  • until = future (until tomorrow)

The Options Parameters

Example

Example Code

javascript
Try it Yourself
const wedding = Temporal.PlainDate.from("2000-05-17");

const today = Temporal.Now.plainDateISO();

const duration = today.since(wedding);

The since() method returns the total number of days, but you can use the largestUnit option to break it down into years and months:

Example

Example Code

javascript
Try it Yourself
const wedding = Temporal.PlainDate.from("2000-05-17");

const today = Temporal.Now.plainDateISO();

const duration = today.since(wedding, {largestUnit:'years'});

PlainTime since()

Example: Plain Time

Example Code

javascript
Try it Yourself
const start = Temporal.PlainTime.from("09:00");

const end = Temporal.PlainTime.from("17:30");

const duration = end.since(start);

ZonedDateTime since()

The since() method calculates the duration between two temporal dates.

Syntax

Example Code

javascript
Try it Yourself
t1.since(t2, options)

Example: ZonedDateTime

Example Code

javascript
Try it Yourself
const start = Temporal.ZonedDateTime.from(

"2026-02-17T09:00:00+01:00[Europe/Oslo]");

const end = Temporal.ZonedDateTime.from(

"2026-02-17T17:30:00+01:00[Europe/Oslo]");

const duration = end.since(start);

Interactive Code Examples

Syntax

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
t1.since(t2, options)

JS Example 2

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
const start = Temporal.PlainDate.from("2026-05-01");

const end = Temporal.PlainDate.from("2026-05-17");



const duration = start.since(end);

Syntax

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
t1.until(t2, options)

JS Example 4

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
const start = Temporal.PlainDate.from("2026-05-01");

const end = Temporal.PlainDate.from("2026-05-17");



const duration = start.until(end);

JS Example 5

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
const start = Temporal.PlainDate.from("2026-05-01");

const end = Temporal.PlainDate.from("2026-05-17");



const duration1 = start.since(end);

const duration2 = start.until(end);

JS Example 6

javascript
Try it Yourself
JavaScript syntax and algorithm demonstration.
const wedding = Temporal.PlainDate.from("2000-05-17");

const today = Temporal.Now.plainDateISO();



const duration = today.since(wedding);