timeFormat(time){ let newTime,hour,minite,seconds; if(time >= 3600){ hour = parseInt(time/3600) < 10 ? '0' + parseInt(time/3600) : parseInt(time/3600) ; minite = parseInt(time%60/60) < 10 ? '0' + parseInt(time%60/60):parseInt(time%60/60); seconds = time%3600 < 10 ? '0' + time%3600 : time%3600; newTime = hour + ':' + minite + ':' + seconds; }else if(time >= 60 && time < 3600){ minite = parseInt(time/60) < 10 ? '0' + parseInt(time/60) : parseInt(time/60); seconds = time%60 < 10 ? '0' + time%60 : time%60; newTime = minite + ':' + seconds; }else if(time < 60 ){ seconds = time < 10 ? '0' + time : time; newTime = '00:'+ seconds; } return newTime; }
转载于:https://blog.51cto.com/xuyran/1966553