Apps show strings like "3 days ago", "in 2 weeks", "yesterday" and "next Sunday" all the time, but PHP has no built-in way to produce them in every language. So developers end up writing their own code for plurals, unit names and word order. This RFC from Weilin Du adds an IntlRelativeDateTimeFormatter class to the intl extension, built on a formatter that ICU (the library intl wraps) already provides.

How it works

You create a formatter for a locale, then pass it a number and a unit:

$formatter = new IntlRelativeDateTimeFormatter('en_US');

echo $formatter->format(-1, IntlRelativeDateTimeFormatterUnit::Day);
// yesterday

echo $formatter->format(2, IntlRelativeDateTimeFormatterUnit::Week);
// in 2 weeks

echo $formatter->formatNumeric(-1, IntlRelativeDateTimeFormatterUnit::Day);
// 1 day ago

Negative numbers mean the past and positive numbers mean the future. format() uses words like "yesterday" when the locale has them, while formatNumeric() always uses a number.

Other locales work the same way:

$french = new IntlRelativeDateTimeFormatter('fr_FR');

echo $french->formatNumeric(-1, IntlRelativeDateTimeFormatterUnit::Day);
// il y a 1 jour

The RFC also adds:

  • Three enums: one for the style (Long, Short, Narrow), one for capitalization, and one for the unit. Units run from Year down to Second, plus the days of the week.
  • An optional NumberFormatter, so you can control how the numbers are formatted.
  • combineDateAndTime(), which joins a relative date and a time into something like "yesterday at 3:45 PM".
  • getErrorCode() and getErrorMessage(), matching other intl classes.

It doesn't accept a date or a timestamp, and it won't pick the unit for you. Your code still decides between "in 7 days" and "in 1 week". It also doesn't replace the IntlDateFormatter::RELATIVE_* styles, which format an actual date.

What it means for existing code

Nothing in intl changes. The RFC adds one class and three enums in the global namespace, so if your code already defines a class with one of those names, it would clash whenever intl is loaded.

Where it stands

It's under discussion and targets PHP 8.7. The page lists a voting period from September 15 to September 29, 2026, but the poll shows no votes yet and the RFC was still being edited on September 22.