calculate difference in two dates in days js code example
Example 1: get the difference between two dates js
const date1 = new Date('7/13/2010');
const date2 = new Date('12/15/2010');
const diffTime = Math.abs(date2 - date1);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
console.log(diffTime + " milliseconds");
console.log(diffDays + " days");
Example 2: calculate days between two dates in javascript
<input id="first" value="25/2/2021"/>
<input id="second" value="26/2/2021"/>