JavaScript 时钟(代码)

来源:互联网 发布:手机做html5软件 编辑:程序博客网 时间:2024/04/30 17:10

JavaScript 时钟(代码):

<html>
<body onload=aaa()>
<script type="text/javascript">
var nowtime ;
var year ;
var month ,date,hours,minutes,seconds,all;
function aaa()
{
nowtime = new Date();
year = nowtime.getYear();
month = nowtime.getMonth()+1;
date = nowtime.getDate();
hours = nowtime.getHours();
minutes = nowtime.getMinutes();
seconds = nowtime.getSeconds();
if (seconds <10)
{
    seconds = "0"+seconds;
}
if (minutes <10)
{
    minutes = "0"+minutes;
}
all = year + " "+month +" "+ date +" "+ hours +":"+minutes+":"+seconds;
time.innerHTML = all;
window.setTimeout("aaa();",100);
}
</script>
<div id="time"></div>
</body>
</html>

原创粉丝点击