javascript difference between two dates
var date1 = new Date();
var date2 = new Date("2025/07/30 21:59:00");
showDiff(date1,date2);
function showDiff(date1, date2){
var diff = (date2 - date1)/1000;
diff = Math.abs(Math.floor(diff));
var days = Math.floor(diff/(24*60*60));
var leftSec = diff - days * 24*60*60;
var hrs = Math.floor(leftSec/(60*60));
var leftSec = leftSec - hrs * 60*60;
var min = Math.floor(leftSec/(60));
var leftSec = leftSec - min * 60;
console.info("You have " + days + " days " + hrs + " hours " + min + " minutes and " + leftSec + " seconds");
return {
d: days,
h: hrs,
i: min,
s: leftSec
};
}