In 2.1.0 of intl-relativeformat I could do new IntlRelativeFormat('en').format(dateObject) and it would return the correct string based on the date, like 2 hours ago or in 3 years or in 5 minutes.
What's the replacement for the previous functionality if I can't do this with Intl.RelativeTimeFormat? Is sticking with the old version of intl-relativeformat the only option?
In 2.1.0 of
intl-relativeformat
I could donew IntlRelativeFormat('en').format(dateObject)
and it would return the correct string based on the date, like2 hours ago
orin 3 years
orin 5 minutes
.The package says it's deprecated now at https://www.npmjs.com/package/intl-relativeformat but the examples there don't say how you can use this new version with any Date object the same as the old version. https://github.com/tc39/proposal-intl-relative-time#take-number-instead-of-date-object-for-input says it's not possible.
What's the replacement for the previous functionality if I can't do this with
Intl.RelativeTimeFormat
? Is sticking with the old version ofintl-relativeformat
the only option?