JSFiddle - React, Tailwind, and code Playground
JavaScript
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };
};
var start_date = 'April 15, 2014';
var end_date = 'April 20, 2014';
var diff = convertMS(Date.parse(end_date) - Date.parse(start_date));
if(diff.d > 1) {
console.log('The difference is more than one day: it is ' + diff.d + ' days!');
}
else {
console.log('The difference is just one day and therefore accepted!');
}