[英]How to get the total hr from start time to end time using 12 Hour Format in php
[英]How to get the total hour from starting time to end time in php
我如何获得从开始时间到结束时间的总小时数。
$start_time = '11:00:00 PM'; // as of 07/08/2013
$end_time = '01:00:00 AM'; // as of 08/08/2013
然后输出应为:
$total = '02:00:00'; // 12 hour format
您可以将日期字符串转换为时间值,然后减去以得到两者之间的秒数差,然后简单地除以3600就可以得到小时数差:
$t1 = strtotime('2013-08-07 23:00:00');
$t2 = strtotime('2013-08-08 01:00:00');
$differenceInSeconds = $t2 - $t1;
$differenceInHours = $differenceInSeconds / 3600;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.