php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41599 setTime() fails after modify() is used
Submitted: 2007-06-05 16:11 UTC Modified: 2008-01-17 20:59 UTC
From: kgrecki at gmail dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.3 OS: Windows/Linux
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: kgrecki at gmail dot com
New email:
PHP Version: OS:

 

 [2007-06-05 16:11 UTC] kgrecki at gmail dot com
Description:
------------
setTime() causes time to move to next Sunday if modify() was called before it. See example. Looks related to Bug #39782
Tested on 5.2.2 Windows & 5.2.3 Linux

Reproduce code:
---------------
date_default_timezone_set('Europe/London');

$start = new DateTime('last Monday');
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//good

$start->modify('Tuesday');
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//good

$start->setTime(0, 0, 0);
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//jumped to next Sunday

$start->setTime(0, 0, 0);
echo $start->format('Y-m-d H:i:s'),PHP_EOL;
//jumped to next Sunday again

Expected result:
----------------
2007-06-04 00:00:00
2007-06-05 00:00:00
2007-06-05 00:00:00
2007-06-05 00:00:00

Actual result:
--------------
2007-06-04 00:00:00
2007-06-05 00:00:00
2007-06-10 00:00:00
2007-06-17 00:00:00

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-17 20:59 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 10:01:28 2024 UTC