可能重复:
Getting the difference between two time/dates using php?
我有两个日期变量 让$ arrival_time =“7.30 AM”; $ departure_time =“8.30 PM”;
然后如何在php中计算这两个变量之间的时差?
答案 0 :(得分:1)
<?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);
?>
答案 1 :(得分:0)
<?php
$am = "7:30AM";
$pm = "8:30PM";
$minutes_diff = round(abs(strtotime($pm) - strtotime($am)) / 60);