Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所有,我有以下代码来计算基于毫秒提供的时间:
$ms = $value['trackTimeMillis']; $track_time = floor($ms/60000).':'.floor(($ms%60000)/1000);
问题是有时这并不能很好地工作。例如,如果我的毫秒数为 246995,这将输出 4:6。
有没有办法让它总是把它转换成正确的,如果它确实舍入到偶数以在它的末尾添加一个零?所以像 2:3 这样的东西会读成 2:30?
谢谢!
是的:
sprintf("%d:%02d", floor($ms / 60000), floor($ms % 60000) / 1000);