时间格式化:时分秒左边加个0
// 12 -> 12
// 5 -> 05
function padLeftZero(time) {
time = time + ""
return ("00" + time).slice(time.length)
}
function formatDuration(duration) {
duration = duration / 1000
// 488s / 60 = 8.12
var minute = Math.floor(duration / 60)
// 488s % 60
var second = Math.floor(duration) % 60
return padLeftZero(minute) + ":" + padLeftZero(second)
}
注:以上内容仅用于日常学习