var getDaysLeft = function (date1, date2) { var daysDiffInMilliSec = Math.abs(new Date(date1) - new Date(date2)); var daysLeft = daysDiffInMilliSec / (1000 * 60 * 60 * 24); return daysLeft;};var date1='2018-05-18';var date2='2018-05-25';var dateDiff = getDaysLeft(date1, date2);console.log(dateDiff);
↧
Answer by Vin S for How do I get the difference between two Dates in JavaScript?
↧