1,获得当日日期 Date();
2,获得从1970到现在的毫秒数 Date().getTime();
3,设置日期 Date().setFullYear(y,m,d) 这样可以获得日期
4,获得是星期几 getDay()
<html>
<body>
<script type="text/javascript"> var d=new Date() var weekday=new Array(7) weekday[0]="星期日" weekday[1]="星期一" weekday[2]="星期二" weekday[3]="星期三" weekday[4]="星期四" weekday[5]="星期五" weekday[6]="星期六" document.write("今天是" + weekday[d.getDay()]) </script>
</body>
</html>
5,获得详细的时间
<html>
<head>
<script type="text/javascript"> function startTime() { var today=new Date() var h=today.getHours() var m=today.getMinutes() var s=today.getSeconds() // add a zero in front of numbers<10 m=checkTime(m) s=checkTime(s) document.getElementById('txt').innerHTML=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="txt"></div>
</body>
</html>