I have 2 Zend_Date objects:
$d1 = new Zend_Date('2011-11-14 12:20:30');
$d2 = new Zend_Date('2012-11-16 13:40:10');
And I need to calculate difference. My output should be like this:
Years: 1, Months: 0, Days: 2, Hours: 1, Minutes: 19, Seconds: 40
I can do it with DateTime
class and diff
method. But my hoster has PHP version < 5.3. Can you help me how can I do it in Zend? Thanks.
There is no implemented function to calculate the difference between two dates, unfortunately.
<?php
$diff = $d2->sub($d1)->toValue();
$days = floor($diff/60/60/24);
$months = floor($diff/60/60/24/30);
?>
This should help you get the variables you need.