计算时间差的方法
作者:互联网
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}`}`; } 计算时间差的方法 单位小时
标签:const,seconds,mss,时间差,60,计算,parseInt,方法,1000 来源: https://www.cnblogs.com/l8l8/p/10530589.html