Skip to content

Novis\Intl\RelativeTime

Writes an amount of time before or after now, such as "3 days ago", the way a language writes it. The method takes a whole list and a locale tag, such as "de", and formats it in one call.

Members

1 member.

MemberSignature
formatformat(array<{ count: int, unit: Unit }> $items, string $locale, ?{ width?: Width, numeric?: Numeric } $options = null): array<string>

Enums

  • Unit { Second, Minute, Hour, Day, Week, Month, Quarter, Year }The unit of time that RelativeTime::format writes. RelativeTime::format writes a count of a unit as a time before or after now. A count of -2 with Week gives "2 weeks ago". A positive count is in the future. Quarter is three months.
  • Numeric { Always, Auto }Whether RelativeTime::format always writes a number. RelativeTime::format writes a time before or after now, such as "in 1 day". Always writes the counts -1, 0 and 1 of Day as "1 day ago", "in 0 days" and "in 1 day". This is the default. Auto writes the same counts as "yesterday", "today" and "tomorrow". Most counts have no word like these, such as the count 5. For such a count, Auto also writes the number: "in 5 days".