时间格式化:时分秒左边加个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)
}
posted @ 2022-03-12 14:39  Wayhome'  阅读(89)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css