JS计时器(非倒计时)_日期时间特效

模板酷站
  •       3/5
  •       1
  •       2
  •       3
  •       4
  •       5
查看演示效果

      织梦DedeCMS视频教程买空间 租服务器 选网硕互联! 无忧站长工具,百度权重一键全查!

      JS倒计时我们见过很多,今天来一个正计时的代码,感觉了新鲜,用来计算在过去某一点距现在多长时间了,也是很实用的功能,其它的可以根据自己的需求修改一下。

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cn"> <head> <title>正计时</title> <meta http-equiv="mrc-type" mrc="text/html; charset=UTF-8"/> <style type="text/css"> #thenceThen{font-size:2em;} </style> <script type="text/javascript" language="javascript"> function thenceThen(timespan){ var date1=new Date(timespan); var totalSecs=(new Date()-date1)/1000; var days=Math.floor(totalSecs/3600/24); var hours=Math.floor((totalSecs-days*24*3600)/3600); var mins=Math.floor((totalSecs-days*24*3600-hours*3600)/60); var secs=Math.floor((totalSecs-days*24*3600-hours*3600-mins*60)); document.getElementById("thenceThen").innerText=timespan+" 距今:"+days+"天"+hours+"小时"+mins+"分钟"+secs+"秒"; } var clock; window.onload=function(){ clock=self.setInterval("thenceThen('2008/12/01')", 500); } </script> </head> <body> <div id="thenceThen"></div> </body> </html>