倒计时以服务器时间计算,下面这段代码有问题。麻烦高手帮忙看看
startclock()
var timerID = null;
var timerRunning = false;
function showtime() {
try{
var http = new XMLHttpRequest;
http.open("HEAD", ".", false);
http.send(null);
var now = new Date(http.getResponseHeader("Date"))
}catch(e){var now = new Date()}
var year = now.getFullYear();
var month = now.getMonth()+1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds()
//var days = parseInt(secondes/(24*3600*1000));
//var nowt = new Date(year+"/"+month+"/"+day+" "+hour+":"+minute+":"+second);
//var destination_t = new Date("2013/5/26 23:59:59")
var Today = null;
var days = parseInt(secondes/(24*3600*1000));
var nowt = new Date(year+"/"+month+"/"+day+" "+hour+":"+minute+":"+second);
var destination_t = new Date("2013/09/22 23:59:59")
var secondes = destination_t.getTime()-nowt.getTime();
var days = secondes>1? parseInt(secondes/(24*3600*1000)):0;
var hours = secondes>1? parseInt((secondes-(days*24*3600*1000))/3600000):0;
var minus = secondes>1? parseInt((secondes-(days*24*3600*1000)-(hours*3600000))/60000):0;
var secondes = secondes>1? parseInt((secondes-(days*24*3600*1000)-(hours*3600000)-(minus*60000))/1000):0;
$(".time_show dd").eq(0).text(days);
$(".time_show dd").eq(1).text(hours);
$(".time_show dd").eq(2).text(minus);
$(".time_show dd").eq(3).text(secondes);
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
var timerID = null;
var timerRunning = false;
function stopclock () {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock () {
stopclock();
showtime();
}
倒计时