Format duration between two dates using Intl.RelativeTimeFormat
OTHER License
A simple browser / node module that leverages Intl.RelativeTimeFormat to print out localized relative durations:
const Duration = require('duration-relativetimeformat');
const duree = new Duration('fr');
console.log(duree.format(Date.now() - 10 * Duration.minute));
> il y a 10 minutes
Only lang is required.
where to and from are either dates, timestamps, or strings.
Non-numeric dates depend on the current date:
Otherwise numeric dates are rounded as much as possible, to avoid things like
etc...