计算时间不同的分钟和秒 [英] Calculate time different in minute and second
本文介绍了计算时间不同的分钟和秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试比较2日期时间,并在几分钟之内得到不同的秒数,之后我引用这个主题如何在PHP中获得时间差异是的,代码可以显示不同的分钟:
i try to compare 2 datetime and get the different in minutes and second and after i refer this topic How to get time difference in minutes in PHP yes that code can show the different but in minute:
$to_time = strtotime("2008-12-13 18:42:00");
$from_time = strtotime("2008-12-13 18:41:58");
echo round(abs($to_time - $from_time) / 60,2). " minute";
所以如何在上面的代码中显示分秒和秒我的php版本是 5.2.17
。
so how to show in minute and second from above code? My php version is 5.2.17
.
推荐答案
$minutes = round(abs($to_time - $from_time) / 60,2);
$seconds = abs($to_time - $from_time) % 60;
echo "$minutes minute, $seconds seconds";
这篇关于计算时间不同的分钟和秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文