zoukankan      html  css  js  c++  java
  • 用js获取实时的获取当前的年月日,时分秒,以及星期

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>系统时间</title>
    <script language="javascript" type="text/javascript">
    <!--
    //获得当前时间,刻度为一千分一秒
    var initializationTime=(new Date()).getTime();
    function showLeftTime()
    {
    var now=new Date();
    var year=now.getYear();
    var month=now.getMonth();
    var day=now.getDate();
    var weekday=now.get
    var hours=now.getHours();
    var minutes=now.getMinutes();
    var seconds=now.getSeconds();
    document.all.show.innerHTML=""+year+""+month+""+day+""+hours+":"+minutes+":"+seconds+"";
    //一秒刷新一次显示时间
    var timeID=setTimeout(showLeftTime,1000);
    }
    
    function showtime() {
    var date = new Date();
    this.year = date.getFullYear();
    this.month = date.getMonth() + 1;
    this.date = date.getDate();
    this.day = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六")[date.getDay()];
    this.hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
    this.minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    this.second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    var currentTime = "现在是:" + this.year + "" + this.month + "" + this.date + "" + this.hour + ":" + this.minute + ":" + this.second + " " +"("+ this.day+")";
    document.all.show.innerHTML=currentTime;
    var timei=setTimeout(showtime,1000);}
    //-->
    </script>
    </head>
    <body onload="showtime()">
    <label id="show">显示时间的位置</label>
    
    </body>
    </html>
  • 相关阅读:
    HashMap与ArrayList的相互嵌套
    Mysql与Oracle 的对比
    什么是子查询
    创建存储过程
    cmd 快捷键
    navicat 快捷键
    Mysql的数据类型 6种
    Mysql与Oracle 的使用区别
    怎样修复ie浏览器
    Linux官方内置Bash中新发现一个非常严重安全漏洞
  • 原文地址:https://www.cnblogs.com/ToFlying/p/3188322.html
Copyright © 2011-2022 走看看