zoukankan      html  css  js  c++  java
  • 5.显示时间

    <!DOCTYPE html>
    <html>
    <head lang="en">
    <meta charset="UTF-8">
    <title>T69-时间</title>
    </head>
    <body>
    <div id="show">time</div>

    <script language="JavaScript" type="text/javascript">
    window.onload = function () {
    showTime();


    }
    function checkTime(i) {
    if (i < 10) {
    i = "0" + i;
    }
    return i;
    }
    var showTime = function () {
    var myDate = new Date();
    var month = myDate.getMonth() + 1;
    var date = myDate.getDate();
    var year = myDate.getFullYear();
    var day = myDate.getDay();
    var h = myDate.getHours();
    var m = myDate.getMinutes();
    var s = myDate.getSeconds();
    m = checkTime(m);
    h = checkTime(h);
    s = checkTime(s);

    var weekday = [];
    weekday[0] = "星期天";
    weekday[1] = "星期一";
    weekday[2] = "星期二";
    weekday[3] = "星期三";
    weekday[4] = "星期四";
    weekday[5] = "星期五";
    weekday[6] = "星期六";


    document.getElementById("show").innerHTML = year + '年' + month + '月' + date + '日' + weekday[day]
    + h + '时' + m + '分' + s + '秒';
    setTimeout(showTime, 500);
    }

    </script>

    </body>
    </html>
  • 相关阅读:
    关于编码的问题(转)
    XML巩固
    浏览器兼容问题的解决方案
    JavaScript 全局变量命名空间生成函数
    表格的使用(转)
    post上传文件
    安装cocoapods
    UILabel内容模糊
    动态获取键盘高度
    iOS多线程同步锁
  • 原文地址:https://www.cnblogs.com/mx2036/p/6704226.html
Copyright © 2011-2022 走看看