|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-20 14:25 UTC] jani@php.net
-Package: Feature/Change Request
+Package: Date/time related
[2010-12-20 14:25 UTC] jani@php.net
-Summary: You cannot initialize a DateTimeZone object by offset
only.
+Summary: Cannot initialize a DateTimeZone object by offset
only
[2014-02-09 20:59 UTC] derick@php.net
-Status: Assigned
+Status: Closed
[2014-02-09 20:59 UTC] derick@php.net
[2014-03-30 19:45 UTC] evert at rooftopsolutions dot nl
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
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