这个代码一直很好用,昨天需要用到就找了出来,但是时分秒却显示NAN NAN NAN ,我什么也没动过。我尝试电脑断网把日期往前调整1个月后刷新网页就正常显示了,我不懂代码,只能求助大神了。希望大神白忙之中帮我修改下,最好能标注上哪里出现的问题,让我这个小白也学习学习。
回复讨论(解决方案)
贴代码。。。
倒计时 <script></script>
<script> <br /> var baselocation = ''; <br /> var importURL = ''; <br /> <br /> var starttime =new Date("3/8/2011 00:00:00"); <br /> <br /> var now = new Date(); <br /> var changeDay = 2; <br /> var endDay = parseInt((now.getDate() + changeDay)/2)*2; <br /> var urodz = new Date((now.getMonth()+1)+"/" + endDay + "/2011 00:00:00"); <br /> urodz.setTime(urodz.getTime() + 1000 * 60 * 60 * 24 * 2); <br /> now.setDate(now.getDate() + changeDay); <br /> $().ready(function() { <br /> GetServerTimesf(); <br /> setInterval("GetServerTimesf()",1000);//用GetServerTimesf <br /> }); <br /> <br /> function GetServerTimesf() { <br /> if(document.getElementById("time_last")!=null){//time_last1 不是 time_last <br /> <br /> now.setTime(now.getTime()+1000); <br /> var days = (urodz - now) / 1000 / 60 / 60 / 24; <br /> var daysRound = Math.floor(days); <br /> var hours = (urodz - now) / 1000 / 60 / 60 - (24 * daysRound); <br /> var hoursRound = Math.floor(hours); <br /> var minutes = (urodz - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound); <br /> var minutesRound = Math.floor(minutes); <br /> var seconds = (urodz - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound); <br /> var secondsRound = Math.round(seconds); <br /> $("#h_01").html(hoursRound); <br /> $("#s_01").html(minutesRound); <br /> $("#m_01").html(secondsRound); <br /> $("#h_02").html(hoursRound); <br /> $("#s_02").html(minutesRound); <br /> $("#m_02").html(secondsRound); <br /> $("#h_03").html(hoursRound); <br /> $("#s_03").html(minutesRound); <br /> $("#m_03").html(secondsRound); <br /> } <br /> } <br /> //结束 </script>