有没有一种更好的方法来计算打开之前的剩余时间-计时器?

时间:2019-05-15 12:17:03

标签: javascript html

我正在编写一个倒数计时器,当到达close时遇到问题,我试图显示timeremaing直到第二天的open。现在,我已经完成了code,但它是在open的同一天而不是第二天进行计算。

以下是整个code的一部分。

var current = new Date();
var day = current.getDay();
var nextday = (nextday) = current.getDay(+1);
var currentTime = (currentTime) = (current.getHours() * 60) + current.getMinutes();
var remainTime = 0;
var closeTime = (openTime[day].close *60);
var openNextday = (openNextday) = nextday - (openTime[nextday].open *60);
var openTime = (openTime[day].open *60);

else if (closeTime - currentTime <= 0) {
     remainTime = currentTime - openNextday;
document.getElementById("hours").innerHTML = "open in " + Math.floor(remainTime/60)+ " hours " + Math.floor(remainTime%60) + " Mins";

}

0 个答案:

没有答案