24小时倒计时脚本,我需要在我的网站24小时倒计时,在每天11:00重置,之后再次启动24小时周期。命中每天00:00 11:00
我不需要这个脚本来控制什么,我只需要它在那里,供游人看到的,所以当他们在10:00访问例如会看到还剩1小时上的时钟,并住了下来计数格式:小时,分钟,秒 ,我需要它忽略客户的时区。
我发现了类似的答案,但有1个小时的窗口,它之后重置,我需要它立即复位,我怎么可以对其进行编辑,以满足我的要求?
这是我发现了什么(这算至21:00将在一楼小时的窗口,比重新开始):
var date;
var display = document.getElementById('time');
$(document).ready(function() {
getTime('GMT', function(time){
date = new Date(time);
});
});
setInterval(function() {
date = new Date(date.getTime() + 1000);
var currenthours = date.getHours();
var hours;
var minutes;
var seconds;
if (currenthours != 21){
if (currenthours < 21) {
hours = 20 - currenthours;
} else {
hours = 21 + (24 - currenthours);
}
minutes = 60 - date.getMinutes();
seconds = 60 - date.getSeconds();
if (minutes < 10) {
minutes = '0' + minutes;
}
if (seconds < 10) {
seconds = '0' + seconds;
}
display.innerHTML = hours + ':' + minutes + ':' +seconds;
} else {
display.innerHTML = 'LIVE NOW';
}
}, 1000);
function getTime(zone, success) {
var url = 'http://json-time.appspot.com/time.json?tz=' + zone,
ud = 'json' + (+new Date());
window[ud]= function(o){
success && success(new Date(o.datetime));
};
document.getElementsByTagName('head')[0].appendChild((function(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = url + '&callback=' + ud;
return s;
})());
}
'currenthours!= 21'只检查小时,无论其21:00或21:59,或其间的任何事物。 – Qirel