ZF-10253: Zend_Date improperly interprets ISO_8601 dates
Description
Description: When passing ISO_8601-compliant dates, complete with timezone, one expects Zend_Date to properly accept and parse that date. However, it does not.
Note the actual result below, Zend_Date ignores the timezone on the date and instead assumes the local timezone (which for me was America/New_York) while DateTime does not.
Code:
<?php $time = '2010-07-29 17:11:52.241004+00'; $dt = new DateTime($time); $dt2 = new Zend_Date($time, Zend_Date::ISO_8601); echo 'Time: ' . $time . ''; echo 'DateTime: ' . $dt->format('c') . '
'; echo 'Zend_Date: ' . $dt2->get(Zend_Date::ISO_8601); ?>
Expected Result: Time: 2010-07-29 17:11:52.241004+00 DateTime: 2010-07-29T17:11:52+00:00 Zend_Date: 2010-07-29T17:11:52+00:00
Actual Result:
Time: 2010-07-29 17:11:52.241004+00 DateTime: 2010-07-29T17:11:52+00:00 Zend_Date: 2010-07-29T17:11:52-04:00
Comments
Posted by Thomas Weidner (thomas) on 2010-07-30T14:01:25.000+0000
Actually wether the millisecond part nor the truncated timezone are proper ISO_8601 inputs.
Posted by Brandon Savage (brandonsavage) on 2010-08-03T06:39:48.000+0000
According to the Wikipedia article on ISO 8601, the truncated UTC offset is valid. (See http://en.wikipedia.org/wiki/ISO_8601/… for more)
The fractional time is not ISO 8601; however, the removal of this does not affect the bug.