Format Dates With Internationalization API: RelativeTimeFormat EN+NL
const differenceInHours = require('date-fns/differenceInHours')
const diff = differenceInHours(
new Date(2021, 6, 2, 6, 50),
new Date(),
)
const rtf = new Intl.RelativeTimeFormat("en");
console.log(rtf.format(diff, 'hour'))
const diff2 = differenceInHours(
new Date(2021, 6, 2, 6, 50),
new Date(),
)
const rtf2 = new Intl.RelativeTimeFormat("nl");
console.log(rtf2.format(diff2, 'hour'))
no comments