<script>
//用户输入总秒数
let second = +prompt('请输入总秒数:')
//计算时分秒
function getTime(t) {
let h = parseInt(t / 60 / 60 % 24)
let m = parseInt(t / 60 % 60 )
let s = parseInt(t % 60)
h = h<10?'0'+h:h
m = m < 10 ? '0'+m :m
s = s < 10 ? '0'+s : s
return `计算之后的时间是${h}小时${m}分钟${s}秒`
}
//打印输出
let str = getTime(second)
document.write(str)
</script>
复制粘贴即可(将秒数转化成时分秒的代码)
let h = parseInt(t / 60 / 60 % 24)20:05:0220:05:03
let m = parseInt(t / 60 % 60 )
let s = parseInt(t % 60)