这个代码一直很好用,前两天需要用到就找了出来,但是时分秒却显示NAN NAN NAN ,我什么也没动过。我尝试电脑断网把日期往前调整1个月后刷新网页就正常显示了,我不懂代码,只能求助大神了。希望大神白忙之中帮我修改下,最好能标注上哪里出现的问题,让我这个小白也学习学习。
今天又打开看了,又正常了,是不是每到月底都会出现问题希望大神们帮我。
<title>倒计时</title>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.5.min.js"></script>
<script type="text/javascript">
var baselocation = '';
var importURL = '';
var starttime =new Date("3/8/2011 00:00:00");
var now = new Date();
var changeDay = 2;
var endDay = parseInt((now.getDate() + changeDay)/2)*2;
var urodz = new Date((now.getMonth()+1)+"/" + endDay + "/2011 00:00:00");
urodz.setTime(urodz.getTime() + 1000 * 60 * 60 * 24 * 2);
now.setDate(now.getDate() + changeDay);
$().ready(function() {
GetServerTimesf();
setInterval("GetServerTimesf()",1000);//用GetServerTimesf
});
function GetServerTimesf() {
if(document.getElementById("time_last")!=null){//time_last1 不是 time_last
now.setTime(now.getTime()+1000);
var days = (urodz - now) / 1000 / 60 / 60 / 24;
var daysRound = Math.floor(days);
var hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound);
var hoursRound = Math.floor(hours);
var minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
var minutesRound = Math.floor(minutes);
var seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
var secondsRound = Math.round(seconds);
$("#h_01").html(hoursRound);
$("#s_01").html(minutesRound);
$("#m_01").html(secondsRound);
$("#h_02").html(hoursRound);
$("#s_02").html(minutesRound);
$("#m_02").html(secondsRound);
$("#h_03").html(hoursRound);
$("#s_03").html(minutesRound);
$("#m_03").html(secondsRound);
}
}
//结束
</script>
</head>
<BODY style="background-image:none;">
<DIV class="sf_count">
<DIV id=time_last>
<SPAN id=h_01>00</SPAN><EM></EM><SPAN id=s_01>00</SPAN><EM></EM><SPAN id=m_01>00</SPAN>
</DIV>