Issues

ZF-12510: Swaped values when using Zend_Date::get() with Zend_Date::YEAR or Zend_Date::YEAR_SHORT

Issue Type:

Bug

Created:

2013-01-18T11:06:59.000+0000

Last Updated:

2013-04-05T16:07:02.000+0000

Status:

Closed

Fix version(s):

Reporter:

Mário Pereira (mariopereira)

Assignee:

None

Tags:

Zend_Date

zend_date

Related issues:

Attachments:

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"

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.