zoukankan      html  css  js  c++  java
  • 动态显示系统时间

      <script language="javascript"> 

    function showtime() 

        var today,hour,second,minute,year,month,date; 
        var strDate ; 
        today
    =new Date(); 
        var n_day 
    = today.getDay(); 
        
    switch (n_day) 
        { 
        
    case 0:{ 
            strDate 
    = "星期日" 
            }
    break
        
    case 1:{ 
            strDate 
    = "星期一" 
            }
    break
        
    case 2:{ 
            strDate 
    ="星期二" 
            }
    break
        
    case 3:{ 
            strDate 
    = "星期三" 
            }
    break
        
    case 4:{ 
            strDate 
    = "星期四" 
            }
    break
        
    case 5:{ 
            strDate 
    = "星期五" 
            }
    break
        
    case 6:{ 
            strDate 
    = "星期六" 
            }
    break
        
    case 7:{ 
            strDate 
    = "星期日" 
            }
    break
        } 
        year 
    = today.getYear(); 
        month 
    = today.getMonth()+1
        date 
    = today.getDate(); 
        hour 
    = today.getHours(); 
        minute 
    =today.getMinutes(); 
        second 
    = today.getSeconds(); 
        
    if(month<10) month="0"+month; 
        
    if(date<10) date="0"+date; 
        
    if(hour<10) hour="0"+hour; 
        
    if(minute<10) minute="0"+minute; 
        
    if(second<10) second="0"+second; 
        document.getElementById(
    'time').innerHTML ="<strong>" +year + "" + month + "" + date + "" + strDate +" " + hour + ":" + minute + ":" + second+"</strong>"//显示时间 
        setTimeout("showtime();"1000); //设定函数自动执行时间为 1000 ms(1 s) 

    </script>
    效果: 2008年08月19日星期二 15:35:47 其中秒部分是一直变化的
     
  • 相关阅读:
    关于For循环的性能
    CLR读书笔记
    轻量级自动化测试框架介绍
    loadrunner中如何将MD5加密的值转换为大写
    LoadRunner 中实现MD5加密
    新安装的soapui启动时报错及解决方法
    单元测试之驱动模块和桩模块的作用和区别
    接口自动化(Python)-利用正则表达式从返回的HTML文本中截取自己想要的值
    LoadRunner性能测试-loadrunner事务
    LoadRunner性能测试-loadrunner工具破解
  • 原文地址:https://www.cnblogs.com/liuhaitao/p/1271307.html
Copyright © 2011-2022 走看看