Header Ads

How to calculate number of days between two dates in javascript?

 



I recommend using the moment.js library (http://momentjs.com/docs/#/displaying/difference/). It handles daylight savings time correctly and in general is great to work with.

Example:

let start = moment("2013-11-03");
let end = moment("2013-11-04");
let diff =end.diff(start, "days")
console.log(diff

No comments

If you have any doubt, please let me know.

Powered by Blogger.