使用 PHP 始终将时间显示为 XX:XX
全部, 我有以下代码来根据提供的毫秒计算时间:
$ms = $value['trackTimeMillis'];
$track_time = floor($ms/60000).':'.floor(($ms%60000)/1000);
问题是有时这效果不太好。例如,如果我的毫秒数为 246995,则输出为 4:6。
有没有办法始终使其正确转换,并且如果它确实四舍五入为偶数,则在其末尾添加零?那么像 2:3 这样的内容会读作 2:30 吗?
谢谢!
All,
I have the following code to figure out a time based on milliseconds that were provided:
$ms = $value['trackTimeMillis'];
$track_time = floor($ms/60000).':'.floor(($ms%60000)/1000);
The issue is that sometimes this doesn't work that well. For example, if I have the milliseconds as 246995 this will output 4:6.
Is there a way to always make it so that it converts this correct and if it does round to an even number to add a zero at the end of it? So something like 2:3 would read 2:30?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的:
Yes: