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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: i dot sonderegger at meteonews dot ch
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC