Having a weird issue with the date stored in a zend date object changing:

Zend_Date::setOptions(array('format_type' => 'php'));//in bootstrap

$start_date = new Zend_Date('2011-05-19','Y-m-d');
$today = new Zend_Date(NULL,'Y-m-d');
$end_date = new Zend_Date('2011-06-19','Y-m-d');

$x = $end_date->sub($today);
$days_left = $x->toValue()/60/60/24;
//$days_left = 4 which is correct 
//$end_date->__toString() at this point is "Jun 19, 2011 12:00:00 AM"

$y = $end_date->sub($start_date);
$days_in_period = $y->toValue()/60/60/24;
//$days_in_period = -15108.9583333
//$end_date->__toString() at this point is "Aug 20, 1928 2:00:00 AM"
If I create a new $end_date object before the second ->sub, I get the
correct $days_in_period (31). Do I really need to do that every time I call
a new method or am I missing something?



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Date-stored-in-zend-date-object-changes-after-a-sub-tp3599126p3599126.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to