我在下面的Javascript中遇到了问题。我正在尝试完成一个倒计时钟,但我得到的结果是关闭,即今天1900小时以下的到期时间
当前时间是17:16:00时还剩11:44:00。它应该是1小时44分钟。它在某处增加了10个小时。
关于我出错的地方的任何想法都已经用相同的结果重写了这个。我知道它还不是干净的代码。我只是原型设计。
此致
var countDownDueTime = new Date('September 26, 2015 19:00:00')
function updateClock() {
var currentTime = new Date();
var currentHours = currentTime.getHours();
var currentMinutes = currentTime.getMinutes();
var currentSeconds = currentTime.getSeconds();
//Pad time to make 2 digit minutes and seconds
currentMinutes = (currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "" ) + currentSeconds;
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
$("#clock").html(currentTimeString);
countDown(currentTime);
}
function countDown(currentTime) {
var difference = new Date(countDownDueTime - currentTime);
var currentHours = difference.getHours();
var currentMinutes = difference.getMinutes();
var currentSeconds = difference.getSeconds();
//Pad time to make 2 digit minutes and seconds
currentMinutes = (currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "" ) + currentSeconds;
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds;
$("#countDown").html(currentTimeString);
}
$(document).ready(function() {
setInterval('updateClock()', 1000);
})