秒 转为小时 分钟 秒
看代码
let timeLong = 118
let hour = Math.floor(timeLong / 3600) < 10 ? '0' + Math.floor(timeLong / 3600) : Math.floor(timeLong / 3600) < 10;
let minute = Math.floor((timeLong - hour * 3600) / 60) < 10
? '0' + Math.floor((timeLong - hour * 3600) / 60)
: Math.floor((timeLong - hour * 3600) / 60);
let second = timeLong - hour * 3600 - minute * 60 < 10
? '0' + (timeLong - hour * 3600 - minute * 60)
: timeLong - hour * 3600 - minute * 60;
console.log(hour + ':' + minute + ':' + second)
最后打印结果是 00:01:58