php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67001 Time functions affected by machine timezone and current time
Submitted: 2014-04-01 13:59 UTC Modified: 2014-04-01 14:17 UTC
From: danmath01 at yahoo dot com dot ar Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Windows + Linux
Private report: No CVE-ID: None
 [2014-04-01 13:59 UTC] danmath01 at yahoo dot com dot ar
Description:
------------
Given an input the DateTime class will produce outputs that are affected by the current default timezone and the current time. The test script provided uses the timestamp for 2013-01-01 00:00:00 and shows that adding 0 minutes can return a result that is 1 hour later. This was observed running the script on the 31st of March 2014, during BST (end of March to end of October), although the localtime should not affect the script. Changing the localtime back 1 week or moving it past October and running the script produces the correct output. This was observed on both Windows with PHP 5.4.7 and on Linux with PHP 5.3.27 and not reproducible on Linux with PHP 5.3.3.


Test script:
---------------
<?php

date_default_timezone_set('Europe/London');

echo date_default_timezone_get(), "\n";

$timestamp= new DateTime("@1356998400");

echo $timestamp->format('Y-m-d H:i:s'), "\n";

$timestamp->modify("+ 0 minutes");

echo $timestamp->format('Y-m-d H:i:s'), "\n";


?>

Expected result:
----------------
Europe/London
2013-01-01 00:00:00
2013-01-01 00:00:00
5.4.7


Actual result:
--------------
Europe/London
2013-01-01 00:00:00
2013-01-01 01:00:00
5.4.7


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-01 14:03 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2014-04-01 14:03 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

I can not reproduce this with PHP 5.4.26 and PHP 5.5.7 (but I can with 5.3.22). Can you please upgrade to a later PHP version?
 [2014-04-01 14:17 UTC] danmath01 at yahoo dot com dot ar
Fixed, checked against 5.4.12
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 08:01:35 2024 UTC