l8l8
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}`}`; 
}

计算时间差的方法 单位小时

 

分类:

技术点:

相关文章:

  • 2021-12-09
  • 2022-02-27
  • 2021-12-09
  • 2021-12-27
  • 2022-12-23
  • 2021-12-27
猜你喜欢
  • 2021-12-27
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案