|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-10-09 12:00 UTC] Octuro at gmail dot com
Description:
------------
Appears that the BST to GMT switch is not been applied correctly
Test script:
---------------
<?php
$objDateTime = new \DateTime("26 October 2014 00:15:00 +0000");
$objDateTime->setTimeZone(new \DateTimeZone('UTC'));
var_dump($objDateTime);
var_dump($objDateTime->getOffSet());
var_dump($objDateTime->getTimeStamp());
var_dump($objDateTime->format("d F Y H:i:s O"));
$objDateTime->setTimeZone(new \DateTimeZone('Europe/London'));
var_dump($objDateTime);
var_dump($objDateTime->getTimeStamp());
var_dump($objDateTime->format("d F Y H:i:s O"));
var_dump($objDateTime->getOffSet());
Expected result:
----------------
string(30) "26 October 2014 00:15:00 +0000"
string(30) "26 October 2014 01:15:00 +0100"
Actual result:
--------------
string(30) "26 October 2014 00:15:00 +0000"
string(30) "26 October 2014 01:15:00 +0000"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 10:00:01 2025 UTC |
I can not reproduce this with PHP 5.5.17 - you filled in "Irrelevant" for PHP version, which is not helpful. In any case, for me, this outputs (after removing your extra var_dumps): derick@whisky:~ $ php /tmp/test.php string(30) "26 October 2014 00:15:00 +0000" string(30) "26 October 2014 01:15:00 +0100" [PHP: 5.5.17-dev ] derick@whisky:~ $ php -v PHP 5.5.17-dev (cli) (built: Sep 22 2014 16:35:00) (DEBUG) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Xdebug v2.3.0dev, Copyright (c) 2002-2013, by Derick Rethans derick@whisky:~ $ cat /tmp/test.php <?php $objDateTime = new \DateTime("26 October 2014 00:15:00 +0000"); $objDateTime->setTimeZone(new \DateTimeZone('UTC')); var_dump($objDateTime->format("d F Y H:i:s O")); $objDateTime->setTimeZone(new \DateTimeZone('Europe/London')); var_dump($objDateTime->format("d F Y H:i:s O"));Hi There was no option in the drop down for my version. I did not think of adding it to the comments. Details are as follows: PHP 5.3.10-1ubuntu3.14 with Suhosin-Patch (cli) (built: Sep 4 2014 07:08:49) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick RethansHi Derick Testing your script on my machine works as expected and the bug is not there. It appears the getTimeStamp causes the issue. Revised script that needs to be run: $objDateTime = new \DateTime("26 October 2014 00:15:00 +0000"); $objDateTime->setTimeZone(new \DateTimeZone('UTC')); var_dump($objDateTime->format("d F Y H:i:s O")); $objDateTime->setTimeZone(new \DateTimeZone('Europe/London')); var_dump($objDateTime->getTimeStamp()); var_dump($objDateTime->format("d F Y H:i:s O")); This has also been tested on the following configuration, and the bug persists: PHP 5.5.9-1ubuntu4.4 (cli) (built: Sep 4 2014 06:56:34) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04.1 LTS" Updating the PHP version and ubuntu version.