php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53225 add-Method of DateTime-class
Submitted: 2010-11-02 08:41 UTC Modified: 2011-11-21 03:06 UTC
From: i dot sonderegger at meteonews dot ch Assigned: danielc (profile)
Status: Duplicate Package: Date/time related
PHP Version: 5.3SVN-2010-11-02 (snap) OS: Mac OS X 10.5.8
Private report: No CVE-ID: None
 [2010-11-02 08:41 UTC] i dot sonderegger at meteonews dot ch
Description:
------------
PHP-Version:
PHP 5.3.99-dev (cli) (built: Nov  1 2010 17:42:09) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2010 Zend Technologies

If a timezone is passed in the time-string to the constructor of the DateTime-Object, a subsequent add() call could result in incorrect results (if the add() call oversteps a daylight-saving time).

Test script:
---------------
// Gives expected result
$date = new DateTime('2010-10-31 01:00 CEST', new DateTimeZone("Europe/Zurich"));
$date->setTimezone(new DateTimeZone('Europe/Zurich'));
$date->add(new DateInterval('PT3H'));
echo $date->format('Y-m-d H:i:sP')."\n";

// Doesn't give expected result
$date = new DateTime('2010-10-31 01:00 CEST', new DateTimeZone("Europe/Zurich"));
$date->add(new DateInterval('PT3H'));
$date->setTimezone(new DateTimeZone('Europe/Zurich'));
echo $date->format('Y-m-d H:i:sP')."\n";

Expected result:
----------------
2010-10-31 04:00:00+01:00
2010-10-31 04:00:00+01:00


Actual result:
--------------
2010-10-31 04:00:00+01:00
2010-10-31 03:00:00+01:00


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-21 03:06 UTC] danielc@php.net
This is a duplicate of https://bugs.php.net/bug.php?id=55253
 [2011-11-21 03:06 UTC] danielc@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: danielc
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC