Issues

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

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

Example:


$date = new Zend_Date();

19.Nov.2009 is set


$date->setDay(31);

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


$date->setMonth(5);

1.May.2009 is set


$date->setYear(2009);

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())

Regards,