-3
可能重复:
Getting the difference between two time/dates using php?AM PM格式的两个日期变量之间的日期差异。
我有两个日期变量 设$ = arrival_time的 “7:30”; $ departure_time =“8.30 PM”;
那么我怎样才能计算这两个变量之间的时差?
可能重复:
Getting the difference between two time/dates using php?AM PM格式的两个日期变量之间的日期差异。
我有两个日期变量 设$ = arrival_time的 “7:30”; $ departure_time =“8.30 PM”;
那么我怎样才能计算这两个变量之间的时差?
<?php
$arrival_time="7.30 AM";
$departure_time="8.30 PM";
$d1= strtotime($arrival_time);
$d2= strtotime($departure_time);
$diff=$d2-$d1;
//Print the difference in hours : minutes
echo date("H:i",$diff);
?>
<?php
$am = "7:30AM";
$pm = "8:30PM";
$minutes_diff = round(abs(strtotime($pm) - strtotime($am))/60);