在 Javascript 中,我需要帮助将百分位整数转换为“分钟:秒.百分位”。
例如,我有这个:“10420”并希望像这样显示它:01:44.20。
有什么想法吗?
最佳答案
function leading0(number){ return number < 10 ? "0" : "";}
mins = parseInt((hundredths / 100) / 60)
secs = parseInt((hundredths / 100) % 60)
huns = parseInt(hundredths % 100)
output = leading0(mins) + mins + ":" + leading0(secs) + secs + "." + leading0(huns) + huns;
jsFiddle 示例:http://jsfiddle.net/cNu2t/
关于javascript - 在javascript中将百分位转换为 “minutes:seconds.hundredths”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12073010/