I keep having trouble with this simple calculation! So, here is a little example to get the amount of days between now and the next occurance of July 1st.

//set up the 2 date objects
$now = new Zend_Date();
$next = new Zend_Date();
//we want July 1st
//if we are currently after july this year
if ($now->get(Zend_Date::MONTH) >= 7) {
//we need to work it out til next July
$next->setYear($now->get(Zend_Date::YEAR) + 1);
else {
//this july is fine
$diff = $next->sub($now)->toValue();
return $diff / 60 / 60 / 24;

By admin

One thought on “Zend_Date – difference between 2 dates”
  1. with me the following worked:

    floor( abs( Zend_Date1->toValue() – Zend_Date2->toValue() ) / 60 / 60 / 24 )

Leave a Reply to Rob Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.