zoukankan      html  css  js  c++  java
  • JS获取当前时间实时显示

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    
    <body>
    <div id="111"></div>
    </body>
    </html>
    <script>
    //获取当前时间函数
    setInterval('showtime()',100);
    function showtime()
    {
        var year,month,day,hour,minute,second;
        var now;
        var today = new Date();
        var week = today.getDay();//获取星期几
        switch(week)
        {
            case 0 :
            {
              week = '星期日';
              break;
            }
            case 1 :
            {
              week = '星期一';
              break;
            }
            case 2 :
            {
              week = '星期二';
              break;
            }
            case 3 :
            {
              week = '星期三';
              break;
            }
            case 4 :
            {
              week = '星期四';
              break;
            }
            case 5 :
            {
              week = '星期五';
              break;
            }
            case 6 :
            {
              week = '星期六';
              break;
            }
        }
        year = today.getFullYear();
        month = today.getMonth()+1;
        day = today.getDate();
        hour = today.getHours();
        minute = today.getMinutes();
        second = today.getSeconds();
        now = '现在是'+year+''+month+''+day+''+week+''+hour+''+minute+''+second+'';
        document.getElementById('111').innerHTML = now;
    }
    </script>
  • 相关阅读:
    python 字符串前面加u,r,b的含义
    文本检测: CTPN
    ocr 识别 github 源码
    python 中写hive 脚本
    Win10 环境安装tesseract-ocr 4.00并配置环境变量
    OCR 识别原理
    pandas set_index和reset_index的用法
    整理 pandas 常用函数
    js es6 map 与 原生对象区别
    js 暂时性死区
  • 原文地址:https://www.cnblogs.com/Itwonderful/p/5679380.html
Copyright © 2011-2022 走看看