Tag Archives: performance

Zend_Date caching

What started with a simple month subtraction function ends with a total nightmare on performance. Using Zend_Date is smart because it can correctly calculate the previous month taking into account months like february and leap years.

public static function previousMonth($year, $month)
{
   $date = new Zend_Date();
   $date->setYear($year);
   $date->setMonth($month);
   $date->sub(1, Zend_Date::MONTH);

   return = array(
      self::$date->get(Zend_Date::YEAR), 
      self::$date->get(Zend_Date::MONTH)
   );
}

Continue reading Zend_Date caching