I’ve got the following DateTime object in php:
[start1] => DateTime Object (
[date] => 2012-05-21 12:59:59
[timezone_type] => 3
[timezone] => Europe/Berlin
)
[end1] => DateTime Object (
[date] => 2012-05-21 22:36:00
[timezone_type] => 3
[timezone] => Europe/Berlin
)
and the result of:
$time->end1->diff($time->start1
is:
DateInterval Object ( [y] => 0 [m] => 0 [d] => 0 [h] => 12 [i] => 36 [s] => 2 [invert] => 1 [days] => 0 )
Why do I get an period of 12 hours and not 9?
I’ve found the solution…Before doing the diff I do a sub() on the start1 object. Now I’ve seen why my result is false… Here is the answer but I REALLY don’t why this is happening.
http://www.php.net/manual/en/datetime.sub.php#101175