Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个我不知道如何解决的问题。这是示例:
$time_start = "13:30"; $time_finish = "03:00";
工人 13:30 开始工作,次日 3:00 结束。三个区域(收费不同):6:00-13:59,14:00-21:59,22:00-5:59
我需要以小时为单位的输出,它会告诉我工人在哪个区域工作了多少小时。只需半个小时。
所以在这个例子中它将是:
第 1 区 - 0.5 , 第 2 区 - 8 , 第 3 区 - 5
我希望它可以理解。非常感谢!
如下您可以计算时间差。
$t1=mktime(13,0,0,5,20,2012); $t2=mktime(13,0,0,5,30,2012); echo date("H:s:i", ($t2-$t1));
看看http://php.net/manual/es/function.mktime.php