Calculate passed time with PHP

ε祈祈猫儿з 提交于 2019-12-06 07:45:42

PHP has a DateInterval class which can be used like so:

$date1 = new DateTime('2013-02-25 12:00:00');
$date2 = new DateTime('2013-01-01 12:00:00');

$diff = $date2->diff($date1); // Get DateInterval Object

echo $diff->format('%d Day and %h hours and %m minutes');
Pannan Mp

you could use date object to get more accurate.
the default var type doesnt give the time difference.
most often they are considered as string types when assinged like you did it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!