JavaScript 秒数转换为天时分秒:简洁高效代码示例
function getaa(sNum) {
const d = Math.floor(sNum / 86400)
const h = Math.floor((sNum % 86400) / 3600)
const m = Math.floor((sNum % 3600) / 60)
const s = sNum % 60
return ${d}-${h}-${m}-${s}
}
// 使用 Math.floor 替代 parseInt,简化计算表达式,提高代码可读性和性能。
原文地址: https://www.cveoy.top/t/topic/orYB 著作权归作者所有。请勿转载和采集!