0 points

Get difference between 2 dates in JavaScript


dashboard

Tue Jul 07 2020 12:14:14 GMT+0000 (UTC)

Posted by @nikhil3790 #javascript

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");
content_copy Copy

https://stackoverflow.com/questions/3224834/get-difference-between-2-dates-in-javascript