Req #45528 [Asn->Csd]: Cannot initialize a DateTimeZone object by offset only

From: Date: Sun, 09 Feb 2014 20:59:02 +0000
Subject: Req #45528 [Asn->Csd]: Cannot initialize a DateTimeZone object by offset only
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184229@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=45528&edit=1 ID: 45528 Updated by: derick@php.net Reported by: tj at systisoft dot com Summary: Cannot initialize a DateTimeZone object by offset only -Status: Assigned +Status: Closed Type: Feature/Change Request Package: Date/time related Operating System: All PHP Version: 5.3CVS-2008-07-16 (CVS) Assigned To: derick Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2008-07-16 09:58:17] tj at systisoft dot com Description: ------------ Sometimes you get timezones from other sources in offset only format. This is often the case when dealing with databases. So yo have sometimes the situation where you have to set a time zone to a DateTime that is only defined by the offset. While an offset alone is not a time zone the DateTimeZone object can handle them by treating them as a time zone without daylight saving and offset, the name of that time zone is the offset itself. This seems to be the way if such time zones are obtained from a DateTime object. It would be nice behavior if new DateTimeZone($d->getName()) will always succeed if $d is a DateTimeZone. Reproduce code: --------------- $d = new DateTimeZone(date_create('+01:00')->getTimeZone()->getName()); echo $d->getName(); Expected result: ---------------- +01:00 Actual result: -------------- PHP Fatal error: Uncaught exception 'Exception' with message 'DateTimeZone::__construct(): Unknown or bad timezone (+01:00)' in Command line code:1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=45528&edit=1

« previous php.bugs (#184229) next »