日期:2014-05-16 浏览次数:20412 次
<html> <head> <script> function setNDateDiff() { var nowdate=new Date() var enddate=new Date("27 May 2012") datediff=enddate-nowdate var dayx=1000*60*60*24 var hourx=1000*60*60 var minx=1000*60 var secx=1000 day=Math.floor(datediff/dayx); hour=parseInt(datediff/hourx-day*24); min=parseInt(datediff/minx-day*24*60-hour*60); sec=parseInt(datediff/secx-day*24*60*60-hour*60*60-min*60); ndatediff="距离考试还有"+day+"天"+(hour<10?'0'+hour:hour)+"小时"+(min<10?'0'+min:min)+"分钟"+(sec<10?'0'+sec:sec)+"秒"; document.write(ndatediff) } </script> </head> <body> <script> setInterval("setNDateDiff()",1000) </script> </body> </html>