当前位置:网站首页>JS calculation time difference

JS calculation time difference

2022-04-23 19:09:00 GIS roast lamb leg is delicious

  /* Calculate the interval time difference   Time type of start time and end time  yyyy-MM-dd HH:mm:ss*/
  static timeCHA(starttime, endtime) {
    var day1 = new Date(starttime);
    var day2 = new Date(endtime);
    if (starttime && endtime != "") {

      // Count the days 
      var timediff = day2 - day1;
      var days = parseInt(timediff / 86400000);
      // Calculate hours 
      var remain = timediff % 86400000;
      var hours = parseInt(remain / 3600000);
      // Count the minutes 
      var remain = remain % 3600000;
      var mins = parseInt(remain / 60000);
      // Calculate seconds 
      var remain = remain % 60000;
      var ss = parseInt(remain / 1000);
      var qx = "";
      if (days > 0) {
        qx += days + " God ";
      }
      if (hours > 0) {
        qx += hours + " when ";
      }
      if (mins > 0) {
        qx += mins + " branch ";
      }
      if (ss > 0) {
        qx += ss + " second ";
      }
    }
    return qx
  }

版权声明
本文为[GIS roast lamb leg is delicious]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231908120794.html