Moment.js - Parse Date Time Ago

If you're using single locale try

moment('Thu Oct 25 2018 17:30:03 GMT+0300').fromNow(); //eg. 1 day ago, 2 hours ago etc

or

moment('Thu Oct 25 2018 17:30:03 GMT+0300').fromNow(true); //eg. 1 day, 2 hours

for more see docs

and:

enter image description here


you can add your date and then compare with the current time:

const timestamp = moment(dateFromDatabase, 'ddd MMM DD YYYY HH:mm:ss GMT Z').fromNow();

or you can also use diff()

const timestamp = moment(dateFromDatabase, 'ddd MMM DD YYYY HH:mm:ss GMT Z').diff(Date.now(), 'hours');

you can change the measurements using years, months, weeks, days, hours, minutes, and seconds.

For more information, you can take a look on here.