zoukankan      html  css  js  c++  java
  • html代码中显示系统时间

    可以显示系统的静态时间和动态时间

    1,静态时间

    <script type="text/javascript">
    var myDate = new Date();
    document.write(myDate.toLocaleString())
    </script>
    静态时间显示

    2,动态时间显示

    <script> 
    function show(){ 
    var date = new Date(); //日期对象 
    var now = ""; 
    now = date.getFullYear()+""; //读英文就行了 
    now = now + (date.getMonth()+1)+""; //取月的时候取的是当前月-1如果想取当前月+1就可以了 
    now = now + date.getDate()+""; 
    now = now + date.getHours()+""; 
    now = now + date.getMinutes()+""; 
    now = now + date.getSeconds()+""; 
    document.getElementById("nowDiv").innerHTML = now; //div的html是now这个字符串 
    setTimeout("show()",1000); //设置过1000毫秒就是1秒,调用show方法 
    } 
    </script> 
    <body onload="show()"> <!-- 网页加载时调用一次 以后就自动调用了--> 
    <div id="nowDiv"></div> 
    </body>
    动态时间显示

    3,精简版的动态时间显示

    <html>
    <head>
    <title>HTML显示时间</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head> 
    <body>
    
    <div id="linkweb">
    </div>
    <script>setInterval("linkweb.innerHTML=new Date().toLocaleString()+' 星期'+'日一
    
    二三四五六'.charAt(new Date().getDay());",1000);
    </script>
    
    
    </body>
    </html>
    精简版的动态时间显示
  • 相关阅读:
    禅道安装
    logstash将配置写在多个文件
    原版Filebeat+ELK
    Filebeat+ELK部署文档
    A-2---Jenkins安装
    Linux ftp服务器搭建
    linux 网络命令
    yum安装时出现No more mirrors to try.
    kvm 修改虚拟机密码
    NFS安装
  • 原文地址:https://www.cnblogs.com/ningheshutong/p/4387397.html
Copyright © 2011-2022 走看看