ZF-8332: Zend_Date fails on 31 of month
Description
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.
Comments
Posted by Thomas Weidner (thomas) on 2009-11-19T02:17:28.000+0000
No problem at all. You are just doing things wrong.
Example:
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.
Posted by Thomas Weidner (thomas) on 2009-11-19T02:18:06.000+0000
Closing as non-issue Wrong usage.
Posted by Daniel Guerrero (danguer) on 2009-11-19T08:52:35.000+0000
Thanks for the clarification, I forgot that date is calculated on each call (I thought that calculation was done on call of getTimestamp())
Regards,