javascript - Comparing two dates Angularjs -


i'm working on piece i'm required calculate difference in time, e.g event has occurred on 22 jan , today 27th jan, want compare 2 dates , display "5 days ago". i'm getting event date json data in timestamp format. clue in how compare todays date , display 'days ago' logic

you can use momentjs , it's diff function.

usage:

moment().diff(moment|string|number|date|array); 

example:

var = moment([2007, 0, 29]); var b = moment([2007, 0, 28]); var difference = a.diff(b, 'days') 

just include script in index.html (or else include them), include moment in controller using regular dependency injection.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -