一、秒数如何转换成时间
function(time){
let hour = Math.floor(time/3600)?Math.floor(time/3600):'00'
// 分钟的计算思路是先除以60算一下有多少分钟,然后整除60,因为满60分钟就转为一小时了,现在算一下不满60分钟的余数,就是剩下多少分钟
let minute = Math.floor(time/60)%60?Math.floor(time/60)%60:'00'
let second = time%60?time%60:'00'
let HMS = hour<10&&hour!=='00'?('0'+hour):hour + ':'+
(minute<10&&minute!=='00'?'0'+minute:minute) + ':'+
(second<10&&second!=='00'?'0'+second:second)
return HMS
}
二、时间转换成秒数
const time = '06:06:06';
const timeArr = time.split(':');
const second = timeArr[0]*3600 + timeArr[1]*60 + timeArr[2]