用PHP格式化持续时间(时间) [英] Formatting Duration (time) in PHP
本文介绍了用PHP格式化持续时间(时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从路线api输出我有一段持续时间,它将使用户从a到达b。目前是分钟,但如果用户的旅程将花费3小时20分钟,则将输出200分钟。
Outputting from a directions api I have a duration it will take the user to get from a to b. At the moment it is minutes but if the users journey will take 3 hours and 20 minutes it will output 200 minutes.
我希望它可以解决60分钟以上的问题。然后除以60,然后将余数除以
I would like it to work out that that is greater than 60 minutes. then divide by 60 and add the remainder to give
3小时20分钟。
我们该如何做。
奇迹
推荐答案
$minutes = 200;
if ($minutes >= 60)
{
$hours = (int)($minutes / 60);
$minutes = $minutes % 60;
}
这篇关于用PHP格式化持续时间(时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文