我想获得完美的时间消耗或从开始时间到结束时间的总时间:
我的代码:
$start_time = $this->input->post('start_time');
$end_time = $this->input->post('end_time');
$t1 = strtotime($start_time);
$t2 = strtotime($end_time);
$differenceInSeconds = $t2 - $t1;
$differenceInHours = $differenceInSeconds / 3600;
if($differenceInHours<0) {
$differenceInHours += 24;
}
在上面的代码中 if $start_time
=它给了我输出11:00:00 PM
而不是. 有没有合适的方法来做到这一点?
因此,如果:$end_date =11:30:00
0.5
30minutes
$start_time = '01:00:00 PM';
$end_time = '01:25:00 PM';
$total = '25:00'; // 25 minutes
或者:
$start_time = '11:00:00 PM';
$end_time = '11:00:25 PM';
$total = '00:00:25'; // 25seconds
问候!