if you suppress the timezone then the timezone will be detected. if you set a timezone within your inputstring then it will be used. You can't really say that this is unexpected behaviour. $date = new Zend_Date(' 10:00:00', Zend_Date::ISO_8601) Įcho $date // note the set timezone Brussels hereĮcho $date // oops. This is the same behaviour as if you would have done If you do not set any timezone than the timezone from default will be used. Why should the timezone be +01 ? You set the timezone within your ISO String to +00 which is equal to GMT. While I expected it to be : 11:00:00 Since Brussels is GMT+1. ĭate_default_timezone_set('Europe/Brussels') Those have to be displayed on a website to people in different timezones (they choose their timezone in a config panel). I'm using a PostgreSQL database with timestamps with timezone in it. So I tried it with the code from SVN trunk, but I'm not satisfied with the behavior. I ran into this problem today using Zend Framework 1.0.3. Also an additional method getTimezoneFromString() has been added. Timezone settings are now used and set as internal timezone if given. Posted by Adam Jensen (jazzslider) on T11:21:25.000+0000Īligned equal signs in code example for better readability. Beyond that, it would be much more intuitive, as developers specifying timezone offsets in their date strings are probably expecting it to "just work" I know that was my experience :) It would be much more convenient to the developer if the constructor simply respected the timezone offset provided in the date string itself. Without knowing the timezone offset in advance, the developer will have to extract it from the string using regular expressions, which is an extra complexity many developers could do without. This is much less convenient to the developer than simply specifying the date string in the constructor, and becomes particularly difficult when the developer is trying to process a dynamic collection of ISO 8601 dates in a variety of valid formats from a variety of timezones. $dateInCustomTimezone->set($stringInCustomTimezone, Zend_Date::ISO_8601) $dateInCustomTimezone->set('+09:00', Zend_Date::GMT_DIFF_SEP) The only way to produce the correct timestamps given the current functionality of Zend_Date is to set the timezone offset prior to setting the rest of the date, like so: The above code, given Zend_Date 1.0.2, produces identical timestamps for both date objects, even though the original strings referred to two different moments in time. PHP_EOL Įcho $dateInCustomTimezone->get(Zend_Date::TIMESTAMP). $dateInCustomTimezone = new Zend_Date($stringInCustomTimezone, Zend_Date::ISO_8601) Įcho $dateInDefaultTimezone->get(Zend_Date::TIMESTAMP). $dateInDefaultTimezone = new Zend_Date($stringInDefaultTimezone, Zend_Date::ISO_8601) For example: ĭate_default_timezone_set('America/Chicago') Reporter: Adam Jensen (jazzslider) Assignee: Thomas Weidner (thomas) Tags: - Zend_DateĬurrently the Zend_Date constructor ignores timezone offsets specified in ISO 8601 date strings. ZF-2071: Zend_Date Constructor should respect timezone offsets in ISO 8601 date strings
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |