JavaScript对象 Date
一、常用的方法
①getFullYear取得年数
②getMonth取得月数0到11
③getDate取得一月中的某一天[0,31]
④getDay取得一周中的某一天[0,6]
⑤getHours小时0到23
⑥getMinutes分钟0到59
⑦getSeconds秒0到59
⑧getMilliseconds毫秒0到999
⑨getTime从19700101至今的毫秒数
二、显示时间的js
function startTime()
{
var today=new Date()
var h=today.getHours()
var m=today.getMinutes()
var s=today.getSeconds()
//var mm=today.getMilliseconds();
var y=today.getFullYear();
var m=today.getMonth();
var d=today.getDate();
m=checkTime(m)
s=checkTime(s)
d=checkTime(d);
document.getElementById('txt').innerHTML=h+":"+m+":"+s+":"+mm+" "+d+"-"+m+"-"+y
setTimeout('startTime()',1
}
function checkTime(i)
{
if (i<10)
{i="0" + i}
return i
}
function checkMM(i)
{
if(i<10)
{i="00" + i}
else
if(i<100)
{i="0" + i}
return i;
}