日期:2014-05-16  浏览次数:20359 次

关于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">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>无标题文档</title>  
<script type="text/javascript">  
<!--   
function startTime()   
{   
var today=new Date()   
var years=today.getFullYear();   
var months=today.getMonth();   
var d=today.getDate()   
var h=today.getHours()   
var m=today.getMinutes()   
var s=today.getSeconds()   
// add a zero in front of numbers<10  
monthsmonths=months+1   
months=checkTime(months)   
d=checkTime(d)   
m=checkTime(m)   
s=checkTime(s)   
var weekday=new Array(7)   
weekday[0]="星期日"   
weekday[1]="星期一"   
weekday[2]=" 星期二"   
weekday[3]="星期三"   
weekday[4]="星期四"   
weekday[5]="星期五"   
weekday[6]=" 星期六"   
var w=weekday[today.getDay()]   
document.getElementById('ShowTime').innerHTML=years+" 年"+months+"月"+d+"日 "+w+" "+h+":"+m+":"+s;   
t=setTimeout('startTime()',500)   
}   
function checkTime(i)   
{   
if (i<10)   
  {i="0" + i}   
  return i   
}   
-->  
</script>    
</head>  
  
<body onload="startTime()">  
<div id="ShowTime"></div>    
</body>  
</html>