显示当前系统时间(new date()..getHours())

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/qq_32077521/article/details/97615743
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
</head>
<body>
    <script type="text/javascript">
        window.onload = function () {
            setInterval(function () {
                var nowTime = new Date();
                var hour = nowTime.getHours();
                var minute = nowTime.getMinutes();
                var second = nowTime.getSeconds();
                hour = hour < 10 ? '0' + hour : hour;
                minute = minute < 10 ? '0' + minute : minute;
                second = second < 10 ? '0' + second : second;
                document.body.innerText = '当前系统时间为:' + hour + ':' + minute + ':' + second;
            }, 1000);
        };
    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_32077521/article/details/97615743
今日推荐