zoukankan      html  css  js  c++  java
  • js动态增加秒数(自动,手动)

    //获取当前的日期及时间Date

     var myDate = new Date();  
        myDate.getYear();        //获取当前年份(2位)  
        myDate.getFullYear();    //获取完整的年份(4位,1970-????)  
        myDate.getMonth();       //获取当前月份(0-11,0代表1月)  
        myDate.getDate();        //获取当前日(1-31)  
        myDate.getDay();         //获取当前星期X(0-6,0代表星期天)  
        myDate.getTime();        //获取当前时间(从1970.1.1开始的毫秒数)  
        myDate.getHours();       //获取当前小时数(0-23)  
        myDate.getMinutes();     //获取当前分钟数(0-59)  
        myDate.getSeconds();     //获取当前秒数(0-59)  
        myDate.getMilliseconds();    //获取当前毫秒数(0-999)  
        myDate.toLocaleDateString();     //获取当前日期  
        var mytime=myDate.toLocaleTimeString();     //获取当前时间  
        myDate.toLocaleString( );        //获取日期与时间  

    //js自动1秒增加

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <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 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);
    }
    //-->
    </script>
    </head>
    <body onload="showLeftTime()">
    <label id="show">显示时间的位置</label>

    </body>
    </html>

    //手动增加减少

    var date=new Date();
    $(".time").find('.timeNum').text(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds())

    $("#add").click(function() {
    date.setSeconds(date.getSeconds()+1);
    $(".time").find('.timeNum').text(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds())

    });
    $("#reduce").click(function() {
    date.setSeconds(date.getSeconds()-1);
    $(".time").find('.timeNum').text(date.getHours()+":"+date.getMinutes()+":"+date.getSeconds())

    });

    一分耕耘,一分收获
  • 相关阅读:
    对于数据的测试
    绕过前端,直接调用后端接口的可能性
    API接口自动化之3 同一个war包中多个接口做自动化测试
    API接口自动化之2 处理http请求的返回体,对返回体做校验
    API接口自动化之1 常见的http请求
    DB中字段为null,为空,为空字符串,为空格要怎么过滤取出有效值
    Linux 常用的压缩命令有 gzip 和 zip
    SQL 常用的命令
    JVM内存管理的机制
    Linux 常见命令
  • 原文地址:https://www.cnblogs.com/sure2016/p/5868392.html
Copyright © 2011-2022 走看看