Wednesday, August 3, 2011

Zend Framework: Difference between two dates

In response to a mailing list question, Thomas, the lead developer of the I18n components pointed out that to find the difference between two Zend_Dates, you just have to subtract them:

$date = Zend_Date::now(); 
$diff = $date->sub($birthdate); 
$diff->toString(); 

Useful tip, that I’ve put here mainly so that I can find it again when I need it!

No comments:

Post a Comment