I did not understand why you are getting differences between start and end because mostly for countdowns we use end-time and now difference.
(我不明白您为什么会在开始和结束之间产生差异,因为在倒数计时中,我们大多使用结束时间和现在的差异。)
But anyway I am sending what you want and if you want you can use this function to get a difference between end and now too.(但是无论如何,我都会发送您想要的东西,如果您想要的话,您也可以使用此功能来获得现在和现在之间的差异。)
var getTimeDifference=function(from,to){
var difMs = (from - to);
if(difMs<=0){
return 0 + " days, " + 0 + " hours, " + 0 + " mins";
}else{
var difDays = Math.floor(difMs / 86400000);
var difHrs = Math.floor((difMs % 86400000) / 3600000);
var difMins = Math.round(((difMs % 86400000) % 3600000) / 60000);
return diffDays + " days, " + difHrs + " hours, " + diffMins + " mins";
}
}
var startTime= new Date('12-30-2019 20:00:00');
var endTime= new Date('11-1-2019 16:00:00');
getTimeDifference(endTime,startTime);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…