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>
    精简版的动态时间显示
  • 相关阅读:
    鼠标悬停改变图片方法
    margin IE6中加倍问题
    js菜单效果
    杂谈
    常见的服务器端口号
    .NET 配置文件设置数据库连接属性
    ASP.NET 利用 Microsoft.Office.Interop.Excel 版本导出Excel数据
    DataGridView 绑定List时 属性不显示的解决方法
    C# 基本文件操作
    构建可克隆对象(ICloneable)
  • 原文地址:https://www.cnblogs.com/ningheshutong/p/4387397.html
Copyright © 2011-2022 走看看