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 函数,可以提高代码的性能 // 简化计算公式,减少计算量

JavaScript 秒数转换为天时分秒:优化代码效率

原文地址: https://www.cveoy.top/t/topic/orYs 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录