码迷,mamicode.com
首页 > Web开发 > 详细

用js显示系统当前日期

时间:2019-02-02 23:11:18      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:图片   row   body   idt   array   char   val   date()   title   

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>获取当前的时间</title>
    </head>
    <style>
        #adata{
            height: 30px;
            width: 330px;
            border: brown 3px solid;
        }
    </style>

    <body>
        <div id="adata"></div>
    </body>

</html>
<script language="JavaScript" type="text/javascript">
    
    window.onload = function() {
        window.setInterval("Systime(adata)", 1000);
    }

    function Systime(adata) {
        var now = new Date();
        var year = now.getFullYear();
        var month = now.getMonth();
        var data = now.getDate();
        var day = now.getDay();
        var hour = now.getHours();
        var minu = now.getMinutes();
        var sec = now.getSeconds();
        month = month + 1;
        var arr_week = new Array("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日");
        var week = arr_week[day];
        var time = year + "" + month + "" + data + "" + week + "      " + hour + ":" + minu + ":" + sec;
        adata.innerHTML = "当前时间:  " + time;
    }
</script>

技术图片

 

用js显示系统当前日期

标签:图片   row   body   idt   array   char   val   date()   title   

原文地址:https://www.cnblogs.com/zxrxzw/p/10349245.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!