获取机器上的时间

 1    //计时器
 2 var spans =document.getElementsByTagName("span");
 3 var time=null;
 4 function checkTime(i){
 5     if(i<10){
 6         i="0"+i;
 7         return i;
 8     }
 9     else{
10         return i;
11     }
12 }
13 timer=setInterval(function(){
14     var now=new Date();
15     y=now.getYear();
16     mo=now.getMonth();
17 
18     h=now.getHours();
19     m=now.getMinutes();
20     s=now.getSeconds();
21     s=checkTime(s);
22     spans[0].innerHTML=h+"小时--" +m+"分钟--" + s+"秒--" + y +"年--"+mo+"月 .l";
23 },500);
原文地址:https://www.cnblogs.com/zfj-world/p/4771439.html