gpt4 book ai didi

javascript - 在javascript中将百分位转换为 “minutes:seconds.hundredths”

转载 作者:行者123 更新时间:2023-12-02 19:25:45 25 4
gpt4 key购买 nike

在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com