function timeFn(time) { let timeStr = ''; timeStr += Math.round((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) < 10 ? '0' + Math.round((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) + ':' : Math.round((time % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)) + ':'; timeStr += Math.round((time % (1000 * 60 * 60)) / (1000 * 60)) < 10 ? '0' + Math.round((time % (1000 * 60 * 60)) / (1000 * 60)) + ':' : Math.round((time % (1000 * 60 * 60)) / (1000 * 60)) + ':'; timeStr += Math.round((time % (1000 * 60)) / 1000) < 10 ? '0' + Math.round((time % (1000 * 60)) / 1000) : Math.round((time % (1000 * 60)) / 1000); return timeStr; } console.log(timeFn(123456780987)) //22:33:01
以秒为单位的时间长度转化为时分秒时间格式的时间长度
猜你喜欢
转载自www.cnblogs.com/hjbky/p/9070817.html
今日推荐
周排行