ZF-12432: Trying to clone a Zend_Date object but it returns a different date (and even time)
Description
I been coding some functions in a project that requires operations with dates. In one of the functions i got a problem with an operation and trying to figure it out what happened i found this issue.
When i create a Zend_Date object and try to clone it to perform some operations on the cloned object (and keep the original object "as is") i get a different date when i invoke "getDate" function. Here is an example:
$d = new Zend_Date('2012-04-01', 'yyyy-MM-dd');
echo $d . '; ' . $d->getDate();
$d displays "Apr 1, 2012 12:00:00 AM" but $d->getDate() displays "Apr 2, 2012 12:00:00 AM"
The issue is not all the time, in the next code the date part is cloned correctly (except the time part that is supposed to be 00:00:00):
$d = new Zend_Date('2012-04-23', 'yyyy-MM-dd');
echo $d . '; ' . $d->getDate();
$d displays "Apr 23, 2012 12:00:00 AM" but $d->getDate() displays "Apr 23, 2012 11:00:00 PM"
I though that the problem was the "date format" so i tried a different approach, but it still change the cloned date:
$d = Zend_Date::now();
$d->setMonth(1)->setDay(1);
echo $d . '; ' . $d->getDate()
$d displays "Jan 1, 2012 9:40:15 PM" but $d->getDate() displays "Jan 2, 2012 12:00:00 AM"
Any ideas?
Comments
Posted by Ralph Schindler (ralph) on 2013-04-05T16:07:15.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/21