#39782 [Asn->Csd]: setTime() on a DateTime constructed with a Weekday yields incorrect results

From: Date: Mon, 11 Dec 2006 21:09:01 +0000
Subject: #39782 [Asn->Csd]: setTime() on a DateTime constructed with a Weekday yields incorrect results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-106214@lists.php.net to get a copy of this message
ID: 39782 Updated by: iliaa@php.net Reported By: php at michaelho dot com -Status: Assigned +Status: Closed Bug Type: Date/time related Operating System: Max OS X 10.4.7 PHP Version: 5.2.0 Assigned To: derick New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2006-12-09 15:28:44] iliaa@php.net Derick I think the patch below should take care of this problem http://bb.prohost.org/patch/date.txt ------------------------------------------------------------------------ [2006-12-08 22:40:42] php at michaelho dot com Description: ------------ When calling setTime() on a DateTime that has been constructed with a Weekday (e.g. new DateTime('Wednesday'))... Calling setTime() causes the date to "jump" to the Next Sunday. This happens on each and every call to setTime(). Reproduce code: --------------- <?php $dttTest = new DateTime('Next Wednesday'); print $dttTest->format('D M j Y - H:i:s') . '<br/>'; /* Correctly outputs: "Wed Dec 13 2006 - 00:00:00" */ $dttTest->setTime(12, 0, 0); print $dttTest->format('D M j Y - H:i:s') . '<br/>'; /* EXPECTING: "Wed Dec 13 2006 - 12:00:00" */ /* ACTUAL: "Sun Dec 17 2006 - 12:00:00" */ $dttTest->setTime(12, 0, 0); print $dttTest->format('D M j Y - H:i:s') . '<br/>'; /* EXPECTING: "Wed Dec 13 2006 - 12:00:00" */ /* ACTUAL: "Sun Dec 24 2006 - 12:00:00" */ ?> Expected result: ---------------- Wed Dec 13 2006 - 00:00:00 Wed Dec 13 2006 - 12:00:00 Wed Dec 13 2006 - 12:00:00 Actual result: -------------- Wed Dec 13 2006 - 00:00:00 Sun Dec 17 2006 - 12:00:00 Sun Dec 24 2006 - 12:00:00 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39782&edit=1

« previous php.bugs (#106214) next »