我想显示从天计算的小时分和秒。我不想表现出几天。我怎样才能做到这一点。我正在使用下面的倒计时库
http://www.gieson.com/Library/projects/utilities/countdown/
到目前为止我尝试过的是var myCountdownTest = new Countdown({
time:86400 * 60,
width : 300,
height : 70,
rangeHi:"hour",
style: "flip"
});
</script>
它显示我的HOURS MINUTES和SECONDS但是根据date.means如果剩余的时间是2天5小时。它只显示我5个小时
请帮助我谢谢
答案 0 :(得分:1)
试试这个:
var end = new Date('02/19/2012 10:1 AM');
var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;
function showRemaining() {
var now = new Date();
var distance = end - now;
if (distance < 0) {
clearInterval(timer);
document.getElementById('countdown').innerHTML = 'EXPIRED!';
return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);
document.getElementById('countdown').innerHTML = days + 'days ';
document.getElementById('countdown').innerHTML += hours + 'hrs ';
document.getElementById('countdown').innerHTML += minutes + 'mins ';
document.getElementById('countdown').innerHTML += seconds + 'secs';
}
timer = setInterval(showRemaining, 1000);