#20382 [Opn->Fbk]: strtotime ("Monday", $date) can produce incorrect output

2004-04-08 Thread sniper
 ID:   20382
 Updated by:   [EMAIL PROTECTED]
 Reported By:  nickj-phpbugs at nickj dot org
-Status:   Open
+Status:   Feedback
 Bug Type: Date/time related
 Operating System: *
 PHP Version:  4CVS, 5CVS
 New Comment:

Can you please give a simpler test? (I somehow have a feeling your
script is buggy, not PHP) 




Previous Comments:


[2004-04-08 01:39:23] nickj-phpbugs at nickj dot org

It appears that this problem has not been resolved.



I've downloaded the latest Stable Win32 package snapshot from
http://snaps.php.net/ , in particular this one:
http://snaps.php.net/win32/php4-win32-STABLE-200404080430.zip [I.e.
from roughly 5 after this bug was closed]



Then I've run the test script on it from an above comment. 



This produces the following results:



==

I:\new downloads\just downloaded\php4-win32-STABLE-200404080430>php
bug-20382-test.php

Content-type: text/html

X-Powered-By: PHP/4.3.6RC3-dev



Discrepancy for 2002-3-26 - results were 2002-3-31 vs 2002-4-1

Discrepancy for 2002-3-27 - results were 2002-3-31 vs 2002-4-1

Discrepancy for 2002-3-28 - results were 2002-3-31 vs 2002-4-1

Discrepancy for 2002-3-29 - results were 2002-3-31 vs 2002-4-1

Discrepancy for 2002-3-30 - results were 2002-3-31 vs 2002-4-1

Discrepancy for 2002-3-31 - results were 2002-3-31 vs 2002-4-1

Discrepancy for 2003-3-25 - results were 2003-3-30 vs 2003-3-31

Discrepancy for 2003-3-26 - results were 2003-3-30 vs 2003-3-31

Discrepancy for 2003-3-27 - results were 2003-3-30 vs 2003-3-31

Discrepancy for 2003-3-28 - results were 2003-3-30 vs 2003-3-31

Discrepancy for 2003-3-29 - results were 2003-3-30 vs 2003-3-31

Discrepancy for 2003-3-30 - results were 2003-3-30 vs 2003-3-31

Discrepancy for 2004-3-23 - results were 2004-3-28 vs 2004-3-29

Discrepancy for 2004-3-24 - results were 2004-3-28 vs 2004-3-29

Discrepancy for 2004-3-25 - results were 2004-3-28 vs 2004-3-29

Discrepancy for 2004-3-26 - results were 2004-3-28 vs 2004-3-29

Discrepancy for 2004-3-27 - results were 2004-3-28 vs 2004-3-29

Discrepancy for 2004-3-28 - results were 2004-3-28 vs 2004-3-29

Discrepancy for 2005-3-22 - results were 2005-3-27 vs 2005-3-28

Discrepancy for 2005-3-23 - results were 2005-3-27 vs 2005-3-28

Discrepancy for 2005-3-24 - results were 2005-3-27 vs 2005-3-28

Discrepancy for 2005-3-25 - results were 2005-3-27 vs 2005-3-28

Discrepancy for 2005-3-26 - results were 2005-3-27 vs 2005-3-28

Discrepancy for 2005-3-27 - results were 2005-3-27 vs 2005-3-28

Discrepancy for 2006-3-21 - results were 2006-3-26 vs 2006-3-27

Discrepancy for 2006-3-22 - results were 2006-3-26 vs 2006-3-27

Discrepancy for 2006-3-23 - results were 2006-3-26 vs 2006-3-27

Discrepancy for 2006-3-24 - results were 2006-3-26 vs 2006-3-27

Discrepancy for 2006-3-25 - results were 2006-3-26 vs 2006-3-27

Discrepancy for 2006-3-26 - results were 2006-3-26 vs 2006-3-27

Discrepancy for 2007-3-20 - results were 2007-3-25 vs 2007-3-26

Discrepancy for 2007-3-21 - results were 2007-3-25 vs 2007-3-26

Discrepancy for 2007-3-22 - results were 2007-3-25 vs 2007-3-26

Discrepancy for 2007-3-23 - results were 2007-3-25 vs 2007-3-26

Discrepancy for 2007-3-24 - results were 2007-3-25 vs 2007-3-26

Discrepancy for 2007-3-25 - results were 2007-3-25 vs 2007-3-26

PHP version: 4.3.6RC3-dev

==



What I would expect to happen is that there would not be any
discrepancies. The fact there are discrepancies indicates to me that
this problem is still unresolved.



I understand that there have been two date-related problems solved
recently (#27719 and #27780), but whatever updates were made for those
problems do not appear to have fixed this problem.



[2004-04-03 09:10:33] [EMAIL PROTECTED]

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.





[2003-04-06 18:47:03] scottmacvicar at ntlworld dot com

This is a DST problem by the looks of it. The specific dates mentioned
are when DST takes effect which is the last sunday in March.



[2002-11-12 19:46:28] nickj-phpbugs at nickj dot org

OK, I decided that was needed was some kind of automated testing, so I
wrote it:



#!/root/php4-200211122230 -q

 7, "Monday" => 1, "Tuesday" => 2,
"Wednesday" => 3,

"Thursday" => 4, "Friday" => 5, "Saturday"
=> 6);



// convert into a number

$desired_day_of_week_number = $wee

#20382 [Opn->Fbk]: strtotime ("Monday", $date) can produce incorrect output

2002-11-12 Thread sniper
 ID:   20382
 Updated by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
-Status:   Open
+Status:   Feedback
 Bug Type: Date/time related
 Operating System: Linux Mandrake 7.2
 PHP Version:  4.2.3
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


Your script produces the expected dates for me with latest CVS
snapshot. Please give try it out.



Previous Comments:


[2002-11-12 02:11:16] [EMAIL PROTECTED]

Strtotime() appears to produce incorrect output under some
circumstances - specifically when wanting the date of a particular day
of the week day of the week from a given starting date. For example,
using 2001-3-20 as a starting point, we want the date for the next
Monday. The correct answer is the 26th, but the result produced is the
25th (a Sunday). The correct result is given sometimes, so this appears
to depend on the input.

A sample script to illustrate:
===
#!/root/php-4.2.3 -q
\n";
print "from 2001-3-17, goto monday: " .
getDateWithModifier("2001-3-17", "Monday") . "; should be
2001-3-19.\n";
print "from 2001-3-18, goto monday: " .
getDateWithModifier("2001-3-18", "Monday") . "; should be
2001-3-19.\n";
print "from 2001-3-19, goto monday: " .
getDateWithModifier("2001-3-19", "Monday") . "; should be
2001-3-19.\n";
print "from 2001-3-20, goto monday: " .
getDateWithModifier("2001-3-20", "Monday") . "; should be 2001-3-26
###.\n";
print "from 2001-3-21, goto monday: " .
getDateWithModifier("2001-3-21", "Monday") . "; should be 2001-3-26
###.\n";
print "from 2001-3-22, goto monday: " .
getDateWithModifier("2001-3-22", "Monday") . "; should be 2001-3-26
###.\n";
print "from 2001-3-23, goto monday: " .
getDateWithModifier("2001-3-23", "Monday") . "; should be 2001-3-26
###.\n";
print "from 2001-3-24, goto monday: " .
getDateWithModifier("2001-3-24", "Monday") . "; should be 2001-3-26
###.\n";
print "from 2001-3-25, goto monday: " .
getDateWithModifier("2001-3-25", "Monday") . "; should be 2001-3-26
###.\n";
print "from 2001-3-26, goto monday: " .
getDateWithModifier("2001-3-26", "Monday") . "; should be
2001-3-26.\n";
print "from 2001-3-27, goto monday: " .
getDateWithModifier("2001-3-27", "Monday") . " ; should be
2001-4-2.\n";
print "\n";

print "PHP version: " . phpversion(). "\n";

?>
===

Produces this output:
===
[root@www tmp]# ./script.php 

from 2001-3-17, goto monday: 2001-3-19; should be 2001-3-19.
from 2001-3-18, goto monday: 2001-3-19; should be 2001-3-19.
from 2001-3-19, goto monday: 2001-3-19; should be 2001-3-19.
from 2001-3-20, goto monday: 2001-3-25; should be 2001-3-26 ###.
from 2001-3-21, goto monday: 2001-3-25; should be 2001-3-26 ###.
from 2001-3-22, goto monday: 2001-3-25; should be 2001-3-26 ###.
from 2001-3-23, goto monday: 2001-3-25; should be 2001-3-26 ###.
from 2001-3-24, goto monday: 2001-3-25; should be 2001-3-26 ###.
from 2001-3-25, goto monday: 2001-3-25; should be 2001-3-26 ###.
from 2001-3-26, goto monday: 2001-3-26; should be 2001-3-26.
from 2001-3-27, goto monday: 2001-4-2 ; should be 2001-4-2.

PHP version: 4.2.3
[root@www tmp]#


Expected output: The 6 lines with "###" are expected to produce the
indicated output, but do not.

Problem was noticed today in PHP 4.06, and then verified as being
reproducible in PHP 4.2.3 (same output).

PHP 4.2.3 configured with:
./configure --with-mysql --enable-xml --enable-wddx 





-- 
Edit this bug report at http://bugs.php.net/?id=20382&edit=1