timeago.js
import { format } from 'timeago.js'const date = new Date('2020-05-31')const ago = format(date)
moment.js
import moment from 'moment'const date = new Date('2020-05-31')const ago = moment(date).fromNow()
Intl.RelativeTimeFormat
You could utilize Intl.RelativeTimeFormat and write your own library, but sadly the API is not supported on IE and Safari.