📜  在 php 代码示例中计算从开始日期时间到结束日期时间的总时间

📅  最后修改于: 2022-03-11 14:54:50.091000             🧑  作者: Mango

代码示例1
date1 = new DateTime('2006-04-12T12:30:00');
$date2 = new DateTime('2006-04-14T11:30:00');

$diff = $date2->diff($date1);

$hours = $diff->h;
$hours = $hours + ($diff->days*24);

echo $hours;