note 117862 added to class.datetime
| From: | ryan at amst dot com | Date: | Fri, 21 Aug 2015 20:09:54 +0000 |
| Subject: | note 117862 added to class.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203412@lists.php.net to get a copy of this message | ||
It seems like, due to changes in the DateTimeZone class in PHP 5.5, when creating a date and
specifying the timezone as a a string like 'EDT', then getting the timezone from the date
object and trying to use that to set the timezone on a date object you will have problems but never
know it. Take the following code:
<?php
$date = new DateTime('2015-08-21 15:00:00 EDT') ;
$tz_string = $date->getTimezone()->getName() ;
$tz = new DateTimeZone($tz_string) ;
$date->setTimezone($tz) ;
?>
You would think this code should not change $date at all, but it does. It seems like you can create
a timezone object like 'EDT' but can't use those to set timezones properly. The
process, however does act like it's working without errors.
----
Server IP: 72.52.91.14
Probable Submitter: 98.103.111.174
----
Manual Page -- http://php.net/manual/en/class.datetime.php
Edit -- https://master.php.net/note/edit/117862
Del: integrated -- https://master.php.net/note/delete/117862/integrated
Del: useless -- https://master.php.net/note/delete/117862/useless
Del: bad code -- https://master.php.net/note/delete/117862/bad+code
Del: spam -- https://master.php.net/note/delete/117862/spam
Del: non-english -- https://master.php.net/note/delete/117862/non-english
Del: in docs -- https://master.php.net/note/delete/117862/in+docs
Del: other reasons-- https://master.php.net/note/delete/117862
Reject -- https://master.php.net/note/reject/117862
Search -- https://master.php.net/manage/user-notes.php