0

任何请帮助我将其转换回原始日期格式,尝试使用strtotime($startDate)并给出非常错误的答案!

$startDate = '2012-11-21T20:16:14+02:00';
$endDate = '2012-11-27T23:19:14+02:00';

$date = 2012-11-26;
$time = 20:16:14;
$duration = $endDate - $startDate; // 01:30:00
4

1 回答 1

1

这应该有效:

$startDate = '2012-11-21T20:16:14+02:00';
$endDate = '2012-11-27T23:19:14+02:00';

$duration = strtotime($endDate) - strtotime($startDate);
// 60 seconds * 60 minutes * 24 hours
$days = round($duration / (60 * 60 * 24));
echo 'days difference: '.$days;
于 2012-11-28T17:33:42.980 回答