Possible Duplicate:
PHPDateTime::days
returns trash?
Ok, I don't get this... Could someone explain what I'm doing wrong here?
date_default_timezone_set('Europe/Oslo');
$a = new DateTime('2011-06-20 21:00:00');
$b = new DateTime('2011-06-21 05:30:00');
echo $a->format('Y-m-d H:i:s') . PHP_EOL;
echo $b->format('Y-m-d H:i:s') . PHP_EOL;
echo $a->diff($b)->format('%a days, %h hours, %i minutes and %s seconds');
echo $a->diff($b)->format('%y years, %m months, %d days, %h hours, %i minutes and %s seconds').PHP_EOL;
The output I get is:
2011-06-20 21:00:00
2011-06-21 05:30:00
6015 days, 8 hours, 30 minutes and 0 seconds
0 years, 0 months, 0 days, 8 hours, 30 minutes and 0 seconds
What is up with the days here? Shouldn't it be 0 in both cases?