ID:               20382
 Comment by:       joe at dataport dot tv
 Reported By:      nickj-phpbugs at nickj dot org
 Status:           Assigned
 Bug Type:         Date/time related
 Operating System: *
 PHP Version:      4CVS, 5CVS (2004-04-13)
 Assigned To:      derick
 New Comment:

How's this?

<?php
$day=date("w",strtotime("this monday"));
echo $day;
?>
Outputs: 1

<?php
$day=date("w",strtotime("next monday"));
echo $day;
?>
Outputs: 0

I was going to submit a seperate bug but this definately looks related
even though this is a totally different way of going about getting the
same type of problem.

(I knew Mondays were a little odd, but does strtotime seem to think the
sunday of the next week has an extra second after midnight? As this
example demonstrates it doesn't do it if you prefix the weekday with
"this", just "next" or no prefix at all.)


Previous Comments:
------------------------------------------------------------------------

[2004-04-08 10:13:10] [EMAIL PROTECTED]

This one shows it better:

<?php
    putenv("TZ=Europe/Amsterdam");
    $tStamp = mktime (17, 17, 17, 10, 27, 2004);
    echo "tStamp=". date("l Y-m-d H:i:s T", $tStamp). "\n";
                                                                       
                                                                   
    $strtotime_timestamp = strtotime ("Monday", $tStamp);
    echo "result=". date("l Y-m-d H:i:s T", $strtotime_timestamp).
"\n";
    echo "wanted=Monday 2004-11-01 00:00:00 CET\n";
?>


------------------------------------------------------------------------

[2004-04-08 07:15:26] nickj-phpbugs at nickj dot org

How's this for a short and simple test script?

Applies strtotime() to every day between 1970 and 2037, and gives a
list of everything that looks wrong.

======================================================
<?php
$request_day = "Monday";
for ($i=1; ; $i++) {
    // start at year 1970, bail out at year 2038
    $tStamp = mktime (17,17,17,1,$i,1970);
    if (date("Y", $tStamp) == 2038) break;
    // request a day, check what we got, complain if differs
    $strtotime_timestamp = strtotime ($request_day, $tStamp);
    $result_day = date("l", $strtotime_timestamp);
    if ($result_day != $request_day)
        print "strtotime wrong on: " . date("j-M-Y", $tStamp) . 
               " - gave a $result_day, not a $request_day.\n"; 
}
?>

------------------------------------------------------------------------

[2004-04-08 07:00:17] [EMAIL PROTECTED]

I'm pretty sure the script is buggy. Please give us a test case for ONE
date that is wrong, and comment your code properly too.

------------------------------------------------------------------------

[2004-04-08 04:25:55] [EMAIL PROTECTED]

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


------------------------------------------------------------------------

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

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/20382

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

Reply via email to