zoukankan      html  css  js  c++  java
  • 当前时间

    <!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>
    <script>
    window.onload = function () {
        
        var oBody = document.body;
        
        setInterval( fnTime, 1000 );
        
        function fnTime () {
            var myTime = new Date();
            // number
            var iYear = myTime.getFullYear();
            var iMonth = myTime.getMonth()+1;
            var iDate = myTime.getDate();
            var iWeek = myTime.getDay();
            var iHours = myTime.getHours();
            var iMin = myTime.getMinutes();
            var iSec = myTime.getSeconds();
            var str = '';
            if( iWeek === 0 ) iWeek = '星期日';
            if( iWeek === 1 ) iWeek = '星期一';
            if( iWeek === 2 ) iWeek = '星期二';
            if( iWeek === 3 ) iWeek = '星期三';
            if( iWeek === 4 ) iWeek = '星期四';
            if( iWeek === 5 ) iWeek = '星期五';
            if( iWeek === 6 ) iWeek = '星期六';
            
            str = iYear+ '' +iMonth+''+iDate+''+iWeek+' '+ toTwo(iHours)+' : '+ toTwo(iMin)+' : '+ toTwo(iSec);
            
            oBody.innerHTML = str;
        
        }
        fnTime ();
        
    };
    
    
    function toTwo ( n ) {
        return n < 10 ?  '0' + n : '' + n;//5秒则为05   60秒为00
    }
    
    </script>
    </head>
    <body>
    </body>
    </html>
  • 相关阅读:
    压缩命令
    u盘挂载
    三种不同的空格
    打出圆圈数字①的快捷方法
    循环使用的一个坑
    Python&R:警告信息管理
    Matlab的基本矩阵运算
    R语言-程序执行时间
    Python:n个点的费马问题
    Python网络数据采集(1):博客访问量统计
  • 原文地址:https://www.cnblogs.com/Xuman0927/p/5421179.html
Copyright © 2011-2022 走看看