1 min readApr 9, 2019
True, thank you for the response.
I copied the wrong version, sorry for that, Here is the right function, I fixed in the post.
export function timeAgo (time, fromTime = null) {
const between = (fromTime || Date.now()) / 1000 - Number(time)
if (between < 3600) {
return pluralize(Math.floor(between / 60) || 0, ' minute')
} else if (between < 86400) {
return pluralize(Math.floor(between / 3600) || 0, ' hour')
} else {
return pluralize(Math.floor(between / 86400) || 0, ' day')
}
}