2

I use a react-intl for translating an application. I got a time in seconds which repesents how long did it take to complete a task and I want to show this time as a relative time. ("2 minutes" instead of pure 120 seconds)

But when I use

<FormattedRelative value={0} initialNow={1248341} />

the react-intl returns "21 minutes ago" instead of "2 weeks" is there any way to get rid of that "ago" phrase and show only the translated phrase for given time value?

1 Answers1

0

I had the same problem and didn't found a clean way to do it with react-intl. Instead you can try using humanize-duration package, which seems to be doing good job.

Borys Kupar
  • 1,631
  • 11
  • 24