js date 日期

// getFullYear():获得年份
// getTime():获得年份
// setFullYear():获得年份
// getDay():获得星期
//

<body onload="starttime()">
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>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。