ZF-12510: Swaped values when using Zend_Date::get() with Zend_Date::YEAR or Zend_Date::YEAR_SHORT
Description
When trying to retrieve the year part of a Zend_Date, the constants Zend_Date::YEAR and Zend_Date::YEAR_SHORT return each others value.
Code sample:
$today = new Zend_Date(); // assume it is 2013-01-18 11:00:00 $year = $today->get(Zend_Date::YEAR); // $year should be "2013", it is "13" $shortYear = $today->get(Zend_Date::YEAR_SHORT); // $yearShort should be "13", it is "2013"
Comments
Posted by Frank Brückner (frosch) on 2013-01-18T13:12:56.000+0000
Hi Mário, I can not reproduce your problem. All unit tests are okay.
Here is a test for your example:
Result: OK
Posted by Mário Pereira (mariopereira) on 2013-01-18T14:09:28.000+0000
You are right, there was a piece of information missing that I overlooked.
This behaviour only occurs when you set the 'format' option of Zend_Date to 'php'. I was setting it in the bootstrap and overlooked it in the test code I supplied.
I created an empty project just to test this and found the following: if I use Zend_Date::setOptions(array('format_type' => 'php')), then I get the results I said above. If I do not set that Zend_Date option, then the calls to get work as expected.
but
Is this an expected behaviour? I've been browsing the documentation and it does not say anything about Zend_Date::get() behaviour changing with or without this option.
Posted by Ralph Schindler (ralph) on 2013-04-05T16:07:02.000+0000
This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf1/issues/50