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:

PHP:
  1. $date = Zend_Date::now();
  2. $diff = $date->sub($birthdate);
  3. $diff->toString();


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

Posted by Rob on 27th January 2008 under Tips and Tricks |

One Response to “Difference between two dates”

  1. Ernesto Vargas responded on 08 Jul 2008 at 1:32 am #

    That tip give you the difference as the a whole date but how can you get the different to get the Age for example?

Comments RSS

Leave a Reply