您的位置:首页 > Web前端 > JavaScript

javascript动态显示时间

2012-04-02 05:22 211 查看
<html>

<head>

<title>ok</title>

<script language=JavaScript>

<!--

function showtimes(){

var now=new Date();

var str="现在时间为:";

var year=now.getYear();

var month=now.getMonth()+1;

var day=now.getDate();

var hour=now.getHours();

var minutes=now.getMinutes();

var seconds=now.getSeconds();

str=str+year+"年";

str=str+month+"月";

str=str+day+"日 "

str=str+hour;

str=str+(minutes<10?":0":":")+minutes;

str=str+(seconds<10?":0":":")+seconds;

tim.innerHTML=str;

var ctimer=setTimeout('showtimes()',960);

}

//-->

</script>

</head>

<body onload="showtimes()">

<div class="showtimes" id="tim"></div>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: