Docs
/
dates
Dates
Compare dates, show relative time, and measure durations. Helpful helpers when Intl alone is not quite enough.
timeFrom
Link Copied!
Show how long ago or how far away a date is, like "Now", "1 minute ago", or "in 4 months". Use style "long" for "10 days ago", "short" for "10d ago". Other locales use Intl.RelativeTimeFormat.
timeFrom("2025-06-15T12:00")
1 year ago
Result
timeDifference
Link Copied!
Measure the gap between two dates. With unit set to "auto", you get a breakdown like "2 days 5 hrs". Pick a single unit like "days" to get something like "6212 days".
timeDifference("2025-01-01T00:00", "2025-01-11T00:00")
10 days
Result
combineDates
Link Copied!
combineDates("2025-01-01T10:00:00", "2025-01-31T14:30:00")
1-31 January 2025
Result
isToday
Link Copied!
isToday("2025-06-15T12:00")
false
Result
isPast
Link Copied!
Check if a date is in the past.
isPast("2020-01-01T12:00")
true
Result
isFuture
Link Copied!
Check if a date is in the future
isFuture("2030-01-01T12:00")
true
Result
isSameDay
Link Copied!
Check if two dates fall on the same calendar day in local time.
isSameDay("2025-06-15T08:00", "2025-06-15T20:00")
true
Result
isSameMonth
Link Copied!
Check if two dates fall in the same calendar month in local time.
isSameMonth("2025-06-01T08:00", "2025-06-28T20:00")
true
Result
isDateBetween
Link Copied!
Check if a date falls between a start and end date by timestamp.
isDateBetween("2025-06-15T12:00", "2025-06-01T00:00", "2025-06-30T00:00")
true
Result