Skip to content

Documentation / @jalali-js/i18n / formatRelative

Function: formatRelative() ​

formatRelative(from, to, locale, options?): string

Defined in: relative.ts:46

Format how from sits relative to to in locale.

  • from earlier than to: past ("3 days ago", "۳ روز پیش")
  • from later than to: future ("in 2 months", "۲ ماه دیگر")
  • same day: locale.relative.today

Unit selection uses diffDates() from jalali-js. Digits follow numerals.

Parameters ​

from ​

AnyCalendarDate

to ​

AnyCalendarDate

locale ​

LocalePack

options? ​

FormatRelativeOptions = {}

Returns ​

string