currentTime = 180 //要换算的总秒数
th = parseInt(currentTime / 3600);
ti = parseInt((currentTime - th * 3600) / 60);
ts = parseInt(currentTime - th * 3600 - ti * 60);
if (th < 10) {
th = '0' + th;
}
if (ti < 10) {
ti = '0' + ti;
}
if (ts < 10) {
ts = '0' + ts;
}
console.log(th, ti, ts)
【简单粗暴】秒数换算时分秒
最新推荐文章于 2024-04-29 17:01:02 发布