时钟

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="application/javascript">
        window.onload = function () {
            function show() {
                var div1 = document.getElementById('div1');
                var time = new Date();
                var year = time.getFullYear();
                var month = time.getMonth()+1;
                var date = time.getDate();
                var week = time.getDay();
                var hour = time.getHours();
                var minutes = time.getMinutes();
                var seconds = time.getSeconds();
                var str = '当前时间是:'+year +''+month+''+date+''+ ' '+'星期'+week+' '+hour+''
                +minutes+''+seconds+'';
                div1.innerHTML = str;
            }
            show();
            var timer = setInterval(show,1000);

        }

    </script>
</head>
<body>
    <div id="div1"></div>
</body>
</html>

 

posted @ 2020-03-11 16:25  卢掌柜的  阅读(127)  评论(0)    收藏  举报