[Watch out] Zend_Date performance
Problem - Zend_Date offers small performance
I always try to use objects when I see they are giving me more flexibility than arrays or primitive types.
During my work often I have to operate on dates so I use Zend_Date quite a lot - our project is based on the Zend Framework. But recently I've run a profiler for one of the pages I created and I saw huge impact on the performance that Zend_Date had.
It did speed up development and made it easier but it also made the code much slower. Zend_Date Comparing with the plain PHP DateTime was like 5 to 10 times slower. Even Zend_Date::toString took quite large amount of CPU time.
Solution - use PHP DateTime instead of Zend_Date
Solution for that part of code was replacing the Zend_Date used in the loops (executed even couple hundred times) with DateTime. It was very simple. Also date operations like adding one day is very easy when we have DateTime object - we just need to pass a DateInterval into DateTime::add().
I'm still using Zend_Date for example as the method parameter but in code where I do many date operations I replace it with the DateTime. Thanks to that my scripts are executed much faster.
Some of DateTime features are available since PHP > 5.3 but you can easily use DateTime with older PHP doing small changes in the code.