// getFullYear():获得年份
// getTime():获得年份
// setFullYear():获得年份
// getDay():获得星期
//
<body >
var date=new Date();
document.write(date);
document.write(date.getFullYear());
document.write("时间戳:"+date.getTime());
//自己设置时间
date.setFullYear(2010,1,1);
document.write(date);
//时钟
function starttime(){
// document.write("dsfsdfsdfsdf");
var today =new Date();
var h= today.getHours();
var m= today.getMinutes();
var s=today.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById("timetxt").innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){
starttime();
},500);
}
function checkTime(i){
if(i<10){
i="0"+i;
}
return i;
}
</script>
<div id="timetxt"></div>