视频时长转时分秒

//   视频时长转时分秒
  function durationTrans(a){
    if(!a||a<1){
        return '00:01'
    }
    let duration = ""
    let h = parseInt(a/3600),
        m = parseInt(a%3600/60),
        s = parseInt(a%3600%60);
    if(h>0){
      h = h<10 ? '0'+h : h
      duration += h+":"
    }
    m = m<10 ? '0'+m : m
    s = s<10 ? '0'+s : s
    duration+=m+":"+s
    return duration;
  }

你可能感兴趣的:(音视频,javascript)