setTime() fails after modify() is used

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

 [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.