js动态显示时间

<!DOCTYPE HTML>  
<html>  
<head>  
<meta charset="utf-8">  
<title>时间显示器</title>   
</head>  
<body>
        <div id="d"></div> 
        <script type="text/javascript">  
                var nowTime ;
                function play(){
                var time = new Date();
                nowTime = time.getFullYear()+"年"+time.getMonth()+"月"+time.getDate()+
                   "日"+time.getHours()+"时"+time.getMinutes()+"分"+time.getSeconds()+"秒";
                document.getElementById("d").innerHTML = nowTime;
                }
                setInterval(play,1000);
        </script>         
</body>  
</html>

欢迎分享本文,转载请保留出处:前端ABC » js动态显示时间

赞 (3)
分享到:更多 ()

发表评论 0