zoukankan      html  css  js  c++  java
  • js苹果系统获取时间戳

     
    苹果系统需要 new Date("2019/01/01 00:00:00").getTime();
    事件格式需要是 2019/01/01 00:00:00
     
    下面的方法判断两个时间差,为秒 ,如果为分的话,把除以1000换成除以1000*60,依次类推
      function datedifference(sDate1, sDate2) {  //苹果系统需要 new Date("2019/01/01 00:00:00").getTime()
        var time1 = new Date(sDate1).getTime(); //sDate1和sDate2是2019/01/01 00:00:00格式

    var time2 = new Date(sDate2).getTime();
    
        var dateSpan = Math.abs(time2 - time1);
        var s= Math.floor(dateSpan / 1000);
        return s;
      };
    

      

    获取当前时间

    function pad2(n) { return n < 10 ? '0' + n : n }
     
    function getNowFormatDate() {
        var date = new Date();
        const year = date.getFullYear().toString();
        const month = pad2(date.getMonth() + 1);
        const day = pad2(date.getDate());
        const hour = pad2(date.getHours());
        const minute = pad2(date.getMinutes());
        const seconds = pad2(date.getSeconds());
    
        return `${year}/${month}/${day} ${hour}:${minute}:${seconds}`;
    }
    

      

     
  • 相关阅读:
    Codeforces 841 D
    Codeforces 838 B
    Codeforces 833 C
    Codeforces 101572 D
    Codeforces 101173 C
    Codeforces 444 C
    POJ 3076 Sudoku
    Codeforces 1025 D
    算法笔记--基环树
    Codeforces 1016 E
  • 原文地址:https://www.cnblogs.com/ZhiXing-Blogs/p/15529223.html
Copyright © 2011-2022 走看看