|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-05-19 12:19 UTC] alan at bulbstudios dot com
Description:
------------
Setting a timezone of either BST, GMT+1, Etc/GMT+1 or CEST on a DateTime object seems to modify the time of the object and set the timezone incorrectly.
Works fine on PHP 5.4.28, barring the missing GMT+1.
Test script:
---------------
#!/usr/bin/env php
<?php
echo date_default_timezone_get(), PHP_EOL;
$utc = new DateTimeZone('UTC');
$time = DateTime::createFromFormat('Y-m-d H:i:s', '2014-05-19 11:30:00');
foreach (['BST', 'GMT+1', 'CEST'] as $abbr) {
$time->setTimezone(new DateTimeZone($abbr));
echo "{$abbr}: {$time->format(DATE_RFC822)}", PHP_EOL;
}
Expected result:
----------------
UTC
BST: Mon, 19 May 14 12:30:00 +0100
Etc/GMT+1: Mon, 19 May 14 12:30:00 +0100
GMT+1: Mon, 19 May 14 12:30:00 +0100
CEST: Mon, 19 May 14 14:30:00 +0200
Actual result:
--------------
UTC
BST: Mon, 19 May 14 12:30:00 +0100
Etc/GMT+1: Mon, 19 May 14 11:30:00 -0100
GMT+1: Mon, 19 May 14 13:30:00 +0100
CEST: Mon, 19 May 14 14:30:00 +0100
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 20:00:01 2025 UTC |
The test script is actually: #!/usr/bin/env php <?php date_default_timezone_set('UTC'); echo date_default_timezone_get(), PHP_EOL; $utc = new DateTimeZone('UTC'); $time = DateTime::createFromFormat('Y-m-d H:i:s', '2014-05-19 11:30:00'); foreach (['BST', 'Etc/GMT+1', 'GMT+1', 'CEST'] as $abbr) { $time->setTimezone(new DateTimeZone($abbr)); echo "{$abbr}: {$time->format(DATE_RFC822)}", PHP_EOL; }