react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

Difference between dates in @internationalized/date

Open kevinkucharczyk opened this issue 4 months ago โ€ข 5 comments

Provide a general summary of the feature here

It would be great if it was possible to return the number of years/months/days etc between two dates/datetimes in @internationalized/date. Something like https://moment.github.io/luxon/#/math?id=diffs or https://tc39.es/proposal-temporal/docs/plaindatetime.html#until which can return the difference in a variety of units.

๐Ÿค” Expected Behavior?

A method on the date/time instances that can be called to get a difference between it and another date, like

startDate.diff(endDate) // returns { years: 1, months: 1, ... }

๐Ÿ˜ฏ Current Behavior

Currently no equivalent feature exists.

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

I need to calculate differences between dates to show them in the UI, or change how the UI acts depending on the length of the ranges.

๐Ÿ’ป Examples

No response

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

kevinkucharczyk avatar Jul 22 '25 21:07 kevinkucharczyk