码迷,mamicode.com
首页 > Web开发 > 详细

js date 日期

时间:2015-05-20 02:07:17      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

// 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>

js date 日期

标签:

原文地址:http://www.cnblogs.com/xiezefeng/p/4516044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!