此函数产生的结果为 0:
function time_difference($time1, $time2) {
$dt1 = new DateTime($time1);
$dt2 = new DateTime($time2);
$difference = $dt1->diff($dt2);
var_dump($difference);
}
这是 var_dump 的输出。是的,我确实验证了 $time1 和 $time2 的日期/时间有效。
object(DateInterval)#7 (15) {
["y"]=> int(0)
["m"]=> int(0)
["d"]=> int(0)
["h"]=> int(0)
["i"]=> int(0)
["s"]=> int(0)
["weekday"]=> int(0)
["weekday_behavior"]=> int(0)
["first_last_day_of"]=> int(0)
["invert"]=> int(0)
["days"]=> int(0)
["special_type"]=> int(0)
["special_amount"]=> int(0)
["have_weekday_relative"]=> int(0)
["have_special_relative"]=> int(0)
}
任何帮助表示赞赏。