美文网首页
秒转换为时分秒

秒转换为时分秒

作者: 王思雨_19强化班 | 来源:发表于2021-12-26 18:09 被阅读0次

// 秒转换为时分秒

formateTime() {

  let h = parseInt(this.scoreInfo.spendTime / 3600)

  let minute = parseInt(this.scoreInfo.spendTime / 60 % 60)

  let second = Math.ceil(this.scoreInfo.spendTime % 60) 

 

  const hours = h < 10 ? '0' + h : h

  const formatSecond = second > 59 ? 59 : second

  return `${hours > 0 ? `${hours}:` : ''}${minute < 10 ? '0' + minute : minute}:${formatSecond < 10 ? '0' + formatSecond : formatSecond}`

},

相关文章

网友评论

      本文标题:秒转换为时分秒

      本文链接:https://www.haomeiwen.com/subject/aewsqrtx.html