ZF-8332: Zend_Date fails on 31 of month


I've tested on two servers both with Zend Framework 1.9 and PHP 5.2.6 the following code:

$date = new Zend_Date(); $date->setDay(31); $date->setMonth(5); $date->setYear(2009);

print "DATE: ".date('d/m/Y', $date->getTimestamp());

Outputs: DATE: 01/05/2009

Expected Output: DATE: 31/05/2009

If you put any valid month that have 31 days you will always get 01 as day in the same month.


No problem at all. You are just doing things wrong.


$date = new Zend_Date();

19.Nov.2009 is set


1.Dec.2009 is set Because there is no 31.Nov. So the valid date is used.


1.May.2009 is set


1.May.2009 is set

When working with dates you need eighter to set a date at once, or by setting from highest to lowest value. From Year, to Month, to Day, and not reverse.

You could also set the extend_months option. But this could add other problems when you are not aware of what you are doing.

Closing as non-issue Wrong usage.

Thanks for the clarification, I forgot that date is calculated on each call (I thought that calculation was done on call of getTimestamp())