问题描述
我发现有很多倒计时计时器,它们可以从特定日期/时间倒数到特定日期/时间,但是我需要一个脚本来倒数(而不是时间)-在指定日期内从300减少到1 /时间范围。 例如,倒数计时需要每天从8.00am在每天8.00开始,并全天递减直到直到8.00pm在1结束。 这是我找到的最接近的[https://codepen.io/petyoyo/pen/aVggJz][1],但可以在几秒钟内使用。不幸的是,我对JavaScript知之甚少,无法对其进行调整。谁能帮忙-有可能吗?
// Set the date we're counting down to
var countDownDate = new Date("Dec 11,2017 19:49:00").getTime(); //CHANGE HERE<----
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var Now = new Date().getTime();
// Find the distance between Now an the count down date
var distance = countDownDate - Now;
// Time calculations for days,hours,minutes and seconds
var seconds = Math.floor((distance % (1000 * 60))/1000 ) + //seconds
(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)))*60 + 340000 + // min to sec
(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)))*60*60+ // hours to sec
(Math.floor(distance / (1000 * 60 * 60 * 24)))*60*60*60; // days to sec
// display the result in the element with id="demo"
document.getElementById("demo").innerHTML = seconds;
// If the count down is finished,write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "EXPIRED";
}
},1000);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)