PHP 时差 2 个自定义格式时间


PHP time difference between 2 custom format times

我正在尝试计算 2 个自定义格式时间戳之间的时差,但它总是返回"0"。这是我的代码:

$date1 = "01.02.2015 - 19:12";
$date2 = "01.02.2015 - 19:15";
//Convert them to timestamps.
$date1Timestamp = strtotime($date1);
$date2Timestamp = strtotime($date2);
//Calculate the difference in minutes
$difference = echo round(abs($date2Timestamp - $date1Timestamp)/60);
echo $difference;

您的日期和时间格式不是导致问题的有效strototime格式。