I want to calculate date difference in days, hours, minutes, seconds, milliseconds, nanoseconds. How can I do it?
use Moment.js for all your JavaScript related date-time calculation
Answer to your question is:
var a = moment([2007, 0, 29]); var b = moment([2007, 0, 28]); a.diff(b) // 86400000
Complete details can be found here