note 99309 added to class.datetime
| From: | bf at tbwb dot nl | Date: | Tue, 10 Aug 2010 10:19:18 +0000 |
| Subject: | note 99309 added to class.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171509@lists.php.net to get a copy of this message | ||
If you have timezone information in the time string you construct the DateTime object with, you
cannot add an extra timezone in the constructor. It will ignore the timezone information in the time
string:
$date = new DateTime("2010-07-05T06:00:00Z", new
DateTimeZone("Europe/Amsterdam"));
will create a DateTime object set to "2010-07-05 06:00:00+0200" (+2 being the TZ offset
for Europe/Amsterdam)
To get this done, you will need to set the timezone separately:
$date = new DateTime("2010-07-05T06:00:00Z");
$date->setTimeZone(new DateTimeZone("Europe/Amsterdam");
This will create a DateTime object set to "2010-07-05 08:00:00+0200"
----
Server IP: 69.147.83.197
Probable Submitter: 80.101.120.34
----
Manual Page -- http://www.php.net/manual/en/class.datetime.php
Edit -- https://master.php.net/note/edit/99309
Del: integrated -- https://master.php.net/note/delete/99309/integrated
Del: useless -- https://master.php.net/note/delete/99309/useless
Del: bad code -- https://master.php.net/note/delete/99309/bad+code
Del: spam -- https://master.php.net/note/delete/99309/spam
Del: non-english -- https://master.php.net/note/delete/99309/non-english
Del: in docs -- https://master.php.net/note/delete/99309/in+docs
Del: other reasons-- https://master.php.net/note/delete/99309
Reject -- https://master.php.net/note/reject/99309
Search -- https://master.php.net/manage/user-notes.php