react-intl translate relative time (like 3 minutes and 50 seconds)

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?

Answers:

Answer

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.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.