ID: 48091 User updated by: mwu at oxid8 dot com Reported By: mwu at oxid8 dot com Status: Bogus Bug Type: Date/time related Operating System: CentOS release 5.2 (Final) PHP Version: 5.2.9 New Comment:
The output as you see here is not as expected.. When I do this in php 5.2.6, I get this: Wed, 29 Apr 2009 00:00:00 -0500 Wed, 06 May 2009 00:00:00 -0500 Wed, 13 May 2009 00:00:00 -0500 In php 5.2.9 I get this: Wed, 29 Apr 2009 00:00:00 +0300 Wed, 29 Apr 2009 00:00:00 +0300 Wed, 29 Apr 2009 00:00:00 +0300 Previous Comments: ------------------------------------------------------------------------ [2009-04-27 20:27:14] j...@php.net Try fixing your script first. This works: <?php function test($sInterval,$iNextDate) { $iNextDate = strtotime($sInterval,$iNextDate); echo date("r", $iNextDate), "\n"; $iNextDate = strtotime($sInterval,$iNextDate); echo date("r", $iNextDate), "\n"; $iNextDate = strtotime($sInterval,$iNextDate); echo date("r", $iNextDate), "\n"; } $iNextDate = time(); test("+1 Wed",$iNextDate); test("+1 day",$iNextDate); test("+1 week",$iNextDate); ?> And output is as expected: Wed, 29 Apr 2009 00:00:00 +0300 Wed, 29 Apr 2009 00:00:00 +0300 Wed, 29 Apr 2009 00:00:00 +0300 Tue, 28 Apr 2009 23:26:44 +0300 Wed, 29 Apr 2009 23:26:44 +0300 Thu, 30 Apr 2009 23:26:44 +0300 Mon, 04 May 2009 23:26:44 +0300 Mon, 11 May 2009 23:26:44 +0300 Mon, 18 May 2009 23:26:44 +0300 ------------------------------------------------------------------------ [2009-04-27 20:06:38] mwu at oxid8 dot com Description: ------------ This worked prior to php 5.2.9 (at least its working in 5.2.6) strtotime("+1 Wed",time()) would yield a timestamp that is 1 Wednesday from the current time. So if the current date is Monday April 27,2009 3pm, then the resulting function would return May 6, 2009 3pm. in 5.2.9 executing this function returns the same timestamp. Reproduce code: --------------- function test($sInterval,$iNextDate) { echo "strtotime(\"$sInterval\",$iNextDate);<br/>"; echo $iNextDate = strtotime($sInterval,$iNextDate) . "<br/>"; echo $iNextDate = strtotime($sInterval,$iNextDate) . "<br/>"; echo $iNextDate = strtotime($sInterval,$iNextDate) . "<br/>"; echo "<br/>"; } $iNextDate = time(); test("+1 Wed",$iNextDate); test("+1 day",$iNextDate); test("+1 week",$iNextDate); Actual result: -------------- strtotime("+1 Wed",1240860865); 1240981200 1240981200 1240981200 strtotime("+1 day",1240860865); 1240947265 1241033665 1241120065 strtotime("+1 week",1240860865); 1241465665 1242070465 1242675265 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48091&edit=1