【发布时间】:2012-07-12 14:14:39
【问题描述】:
可能重复:
Getting the difference between two time/dates using php?
我有两个日期变量 让 $arrival_time="7.30 AM"; $departure_time="8.30 PM";
那么如何计算php中这两个变量的时间差呢?
【问题讨论】:
标签: php
可能重复:
Getting the difference between two time/dates using php?
我有两个日期变量 让 $arrival_time="7.30 AM"; $departure_time="8.30 PM";
那么如何计算php中这两个变量的时间差呢?
【问题讨论】:
标签: php
<?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);
【讨论】: