#39782 [Opn->Asn]: setTime() on a DateTime constructed with a Weekday yields incorrect results
| From: | tony2001@php.net | Date: | Fri, 08 Dec 2006 22:53:17 +0000 |
| Subject: | #39782 [Opn->Asn]: 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-106121@lists.php.net to get a copy of this message | ||
ID: 39782
Updated by: tony2001@php.net
Reported By: php at michaelho dot com
-Status: Open
+Status: Assigned
Bug Type: Date/time related
Operating System: Max OS X 10.4.7
PHP Version: 5.2.0
-Assigned To:
+Assigned To: derick
Previous Comments:
------------------------------------------------------------------------
[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