how to calculate a difference between two Zend_Date objects, in months

Posted by Vincenzo on Stack Overflow See other posts from Stack Overflow or by Vincenzo
Published on 2010-06-13T11:45:45Z Indexed on 2010/06/13 11:52 UTC
Read the original article Hit count: 167

Filed under:
|

I have two objects of Zend_Date class and I want to calculate the difference between them in full calendar months.. How can I do this?

<?php
$d1 = new Zend_Date('1 Jan 2008');    
$d2 = new Zend_Date('1 Feb 2010');
$months = $d1->sub($d2)->get(Zend_Date::MONTH);
assert($months == -25); // failure here

Thanks in advance!

© Stack Overflow or respective owner

Related posts about php

Related posts about zend-framework