Format timespan in PHP/CodeIgniter

旧巷老猫 提交于 2019-12-11 09:42:15

问题


I am working on a project that needs to check time difference between a particular time in the past and now, and to output the diff in MINUTES only. Example if the Diff is 2hour 3min. the output should be 123 (ie 2hr(120 minutes) + 3min).

I used CodeIgniter timespan() function, but it only returns something like 2hours 3minutes. Is there a way I can get the required output?


回答1:


Do you need something like this ?

$tomorrow  = mktime(0, 0, 0, date("m")  , date("d")+1, date("Y"));
$today = mktime(0, 0, 0, date("m"), date("d"),   date("Y"));

$minutesDiff = ($tomorrow - $today)/60;
echo $minutesDiff;


来源:https://stackoverflow.com/questions/18151002/format-timespan-in-php-codeigniter

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