Reputation: 1465
Any please help me to covert this back to orignal date formats, have tried to use strtotime($startDate)
and its giving a very wrong answer!
$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
Upvotes: 0
Views: 88
Reputation: 27594
This should work:
$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;
Upvotes: 1