我如何添加45分钟到现有的时间


How do I add 45 minutes to an existing time?

我试图使用strtotime添加两个时间。我使用下面的代码来添加两个时间。
我的期望输出是15:59:00,但它给了我09:30:44。那么问题是什么呢?

提前感谢。

$json['time'] = "15:14";   
$total_duration = "45";   //in minutes
/* convert minutes into hours-minutes */
$hours = intval($total_duration / 60);  
$mins = $total_duration % 60;           
$service_duration = strtotime($hours."00:00")+strtotime("00:".$mins.":00");
/* end time = total service duration + start time */
$start_time = strtotime($json['time'].":00");
echo $service_duration."--".$start_time."==";
$end_time2 = $start_time+$service_duration;   
$end_time = date('H:i:s', $end_time2);echo $end_time;exit;

你可以这样做

$json['time'] = "15:14";   
$total_duration = "45";   //in minutes
$endTime = strtotime("+".$total_duration." minutes", strtotime($json['time']));
echo date('H:i:s', $endTime);
输出:

15:59:00