zoukankan      html  css  js  c++  java
  • 计算时间差的方法

    export function timestampDiff(endTimestamp,startTimestamp) {
      const  mss = endTimestamp - startTimestamp;
      const days = parseInt(mss / (1000 * 60 * 60 * 24) ,10);
      const hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60) ,10) + days * 24;
      const minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60), 10);
      const seconds = parseInt((mss % (1000 * 60)) / 1000 ,10);
      return `${hours.toString().length > 1 ?  hours : `0${hours}`}:${minutes.toString().length > 1 ?  minutes : `0${minutes}`}:${seconds.toString().length > 1 ?  seconds : `0${seconds}`}`; 
    }
    
    计算时间差的方法 单位小时
  • 相关阅读:
    leetcode-409
    leetcode-836
    leetcode-1160
    leetcode-面试题13
    leetcode-695
    go的一些小lib
    leetcode-300
    cookie
    php上传文件
    PHP 文件创建/写入
  • 原文地址:https://www.cnblogs.com/l8l8/p/10530589.html
Copyright © 2011-2022 走看看