12

用JavaScript做一个时间表

<span id="shiji"></span>
<script>
window.setInterval("time()",500);
function time()
{

var now=new Date();
var y=now .getFullYear();
var m=now.getMonth()+1;
var d=now.getDate();
var h=now.getHours();
var m2=now.getMinutes();
var s=now.getSeconds();
document.getElementById("shiji").innerText=y+":"+m+":"+d+":"+h+":"+m2+":"+s;

}
</script>

posted @ 2017-03-27 15:23  陈山河z  阅读(84)  评论(0编辑  收藏  举报