js生成日月年时分秒星期

生成日月年时分秒星期
   使用方法:在body里设置 onLoad="showtime()"然后再需要显示时间的位置引用 <div     id="www_zzje_net"></div>

 

<SCRIPT language=JavaScript>

 var timerID =null;
 var today = new Date();  var week; var date; 
 if(today.getDay()==0) week="星期日"; 
 if(today.getDay()==1) week="星期一"; 
 if(today.getDay()==2) week="星期二"; 
 if(today.getDay()==3) week="星期三"; 
 if(today.getDay()==4) week="星期四"; 
 if(today.getDay()==5) week="星期五"; 
 if(today.getDay()==6) week="星期六"; 
 function showtime ()
 {
  var date = new Date();
  var timeValue = "";
  timeValue = date.getYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日";
  timeValue=timeValue+week;
  timerID = setTimeout("showtime()",1000);
 }

    setInterval("www_zzje_net.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);

</SCRIPT>

你可能感兴趣的:(JavaScript,.net)