Web頁面動態重新整理時間

漁村暮火發表於2018-02-23
        function realSysTime(clock){ 
     	   var now=new Date(); 
     	   var year=now.getFullYear();
     	   var month=now.getMonth();
     	   var date=now.getDate();
     	   var day=now.getDay();
     	   var hour=now.getHours();
     	   var minu=now.getMinutes();
     	   var sec=now.getSeconds();
     	   if(Number(sec)<10){
     		   sec="0"+sec.toString();
     	   }
     	   month=month+1; 
     	   var arr_week=new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六"); 
     	   var week=arr_week[day]; 
     	   var time=year+"年"+month+"月"+date+"日 "+week+" "+hour+":"+minu+":"+sec; //組合系統時間 
     	   clock.innerHTML=time;
     	} 
     	window.onload=function(){ 
     	   window.setInterval("realSysTime(clock)",1000);
     	}
	

<div class="symTime" id="clock"></div>

頁面動態重新整理時間,每秒重新整理一次。


相關文章