1 <div class="time">您好,今天是: <span id=localtime></span> 2 <script type="text/javascript"> 3 function showLocale(objD) 4 { 5 var str,colorhead,colorfoot; 6 var yy = objD.getYear(); 7 if(yy<1900) yy = yy+1900; 8 var MM = objD.getMonth()+1; 9 if(MM<10) MM = '0' + MM; 10 var dd = objD.getDate(); 11 if(dd<10) dd = '0' + dd; 12 var hh = objD.getHours(); 13 if(hh<10) hh = '0' + hh; 14 var mm = objD.getMinutes(); 15 if(mm<10) mm = '0' + mm; 16 var ss = objD.getSeconds(); 17 if(ss<10) ss = '0' + ss; 18 var ww = objD.getDay(); 19 if ( ww==0 ) colorhead="<font color="#ffffff">"; 20 if ( ww > 0 && ww < 6 ) colorhead="<font color="#ffffff">"; 21 if ( ww==6 ) colorhead="<font color="#ffffff">"; 22 if (ww==0) ww="星期日"; 23 if (ww==1) ww="星期一"; 24 if (ww==2) ww="星期二"; 25 if (ww==3) ww="星期三"; 26 if (ww==4) ww="星期四"; 27 if (ww==5) ww="星期五"; 28 if (ww==6) ww="星期六"; 29 colorfoot="</font>" 30 str = colorhead + yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss + " " + ww + colorfoot; 31 return(str); 32 } 33 function tick() 34 { 35 var today; 36 today = new Date(); 37 document.getElementById("localtime").innerHTML = showLocale(today); 38 window.setTimeout("tick()", 1000); 39 } 40 tick(); 41 </script> 42 </div>