Zend_Date :: toString () returns the wrong year. Error in my code or Zend_Date?

I use Zend_Date to set and get the year, but it is not set as the correct year. I set the year in 2010, and it returns the year in 2009. What am I doing wrong? Is there a bug in Zend_Date ?

 $date = new Zend_Date('2010-01-03', 'YYYY-MM-dd'); echo $date->toString('MMMM d, YYYY'); //outputs January 3, 2009 

The year must be set correctly, because the annual part of the date works:

 echo $date->get(Zend_Date::YEAR); //2010 

Decision:

Well, I got it to work ... You use lower case: yyyy

 echo $date->toString('MMMM d, yyyy'); 
  • yyyy means ISO year . 2010-01-03 - Week 53, 7th day of ISO 2009.
  • yyyy indicates the actual calendar year.
+7
zend-framework
source share
1 answer

I ran into this problem.

In the Zend_Date class, "YYYY" means the four-digit representation of the "year of ISO", where "yyyy" means the four-digit representation of the "year".

+11
source share

All Articles