ID:               38781
 Updated by:       [EMAIL PROTECTED]
 Reported By:      rpk at npstrategy dot com
-Status:           Wont fix
+Status:           Bogus
 Bug Type:         Date/time related
 Operating System: Linux Fedora Core 4
 PHP Version:      4.4.4
 New Comment:

<?php
/*
 * The United States changed Daylight Savings Time
 * Start:
 *   <= 2006:  First Sunday in April at 2:00 am
 *   >= 2007:  Second Sunday in March at 2:00 am
 * End:
 *   <= 2006:  Last Sunday in October at 2:00 am
 *   >= 2007:  First Sunday in November at 2:00 am
 *
 * http://aa.usno.navy.mil/faq/docs/daylight_time.html
 */

// SPRING  ------------------------------
// 2006
//$t1 = strtotime('2006-03-05 02:30:00');
//$t2 = strtotime('2006-03-05 01:30:00');
//
// 2007
//$t1 = strtotime('2007-03-04 01:30:00');
//$t2 = strtotime('2007-03-04 02:30:00');
// --------------------------------------

// FALL  --------------------------------
// 2006
//$t1 = strtotime('2006-10-22 01:30:00');
//$t2 = strtotime('2006-10-22 02:30:00');
//
// 2007
$t1 = strtotime('2007-10-21 01:30:00');
$t2 = strtotime('2007-10-21 02:30:00');
// --------------------------------------

$step = 60 * 60 * 24 * 7;  // Increment one week

for ($i = 0; $i < 6; $i++) {
    echo $t1 . ' = ' . date('r', $t1) . "\n";
    echo $t2 . ' = ' . date('r', $t2) . "\n";
    echo "---\n";
    $t1 = $t1 + $step;
    $t2 = $t2 + $step;
}


OUTPUT:
-------
1192944600 = Sun, 21 Oct 2007 01:30:00 -0400
1192948200 = Sun, 21 Oct 2007 02:30:00 -0400
---
1193549400 = Sun, 28 Oct 2007 01:30:00 -0400
1193553000 = Sun, 28 Oct 2007 02:30:00 -0400
---
1194154200 = Sun, 04 Nov 2007 01:30:00 -0400
1194157800 = Sun, 04 Nov 2007 01:30:00 -0500
---
1194759000 = Sun, 11 Nov 2007 00:30:00 -0500
1194762600 = Sun, 11 Nov 2007 01:30:00 -0500
---
1195363800 = Sun, 18 Nov 2007 00:30:00 -0500
1195367400 = Sun, 18 Nov 2007 01:30:00 -0500
---
1195968600 = Sun, 25 Nov 2007 00:30:00 -0500
1195972200 = Sun, 25 Nov 2007 01:30:00 -0500


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

[2006-09-12 08:31:43] [EMAIL PROTECTED]

I still can not reproduce it.
month11_2006_date for Friday 2006 = 17(correct)
month11_2007_date = 16 (wrong)

Anyway, we're not going to do any major changes in PHP4.
The datetime related code was rewritten in 5.1, which you should use
instead.

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

[2006-09-11 21:28:49] rpk at npstrategy dot com

running program
http://southo.org/date_test.php


Code:

$month11_2006_timestamp = mktime(0,0,0,11,1,2006);

$month11_2006_day_timestamp = strtotime("3
Friday",$month11_2006_timestamp);

$month11_2006_date = date('j',$month11_2006_day_timestamp);

echo"<h1>month11_2006_date for Friday 2006 = $month11_2006_date
(correct)</h1>";


$month11_2007_timestamp = mktime(0,0,0,11,1,2007);

$month11_2007_day_timestamp = strtotime("3
Friday",$month11_2007_timestamp);

$month11_2007_date = date('j',$month11_2007_day_timestamp);

echo"<h1>month11_2007_date = $month11_2007_date (wrong)</h1>";

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

[2006-09-11 18:29:09] [EMAIL PROTECTED]

Can't reproduce with both 4.4 and 5.2.

I get 17 and 16, both are correct results.

Also, please try to be more clear when you provide reproduce code. Lot
of HTML and text do not add any understanding.

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

[2006-09-11 18:16:17] rpk at npstrategy dot com

Description:
------------
strtotime starts generating wrong timestamps in November, 2007.  Only
wrong in the month of November.  Rest of months are ok.

strtotime("3 Friday", $november_2006_timestamp) generates correct
timestamp with date which is the 3rd Friday in November 2006.

strtotime("3 Friday", $november_2007_timestamp) generates wrong
timestamp with date which should be the 3rd Friday in November 2007. 
The date generated is -1 day, in this case, Thursday in the month of
November, 2007.

All dates generated are wrong in the months of November.  Tested up to
2009.  Every other month works ok.




Reproduce code:
---------------
<?php
$month11_2006_timestamp = mktime(0,0,0,11,1,2006);

$month11_2006_day_timestamp = strtotime("3
Friday",$month11_2006_timestamp);

$month11_2006_date = date('j',$month11_2006_day_timestamp);

echo"<h1>month11_2006_date for Friday 2006 = $month11_2006_date
(correct)</h1>";

echo"<h1>This correctly shows the 3rd Friday date for November, 2006
</h1>";

//test of strtotime() generating date string for day in 3 week in
November 2007

$month11_2007_timestamp = mktime(0,0,0,11,1,2007);

$month11_2007_day_timestamp = strtotime("3
Friday",$month11_2007_timestamp);

$month11_2007_date = date('j',$month11_2007_day_timestamp);

echo"<h1>month11_2007_date = $month11_2007_date (wrong)</h1>";

echo"<h1>This incorrectly shows the 3rd Friday date for November, 2007

         <br>as the 15th of November 2007 which is a Thursday.
         <p>Every day-date generated from November 2007-2009 produces at -1
day from the standard.
             So other days are also wrong.  It is always November. The other
months work fine.</p></h1>";

Expected result:
----------------
month11_2006_date for Friday 2006 = 17 (correct)
This correctly shows the 3rd Friday date for November, 2006
month11_2007_date = 15 (wrong)
This incorrectly shows the 3rd Friday date for November, 2007
as the 15th of November 2007 which is a Thursday.

Every day-date generated from November 2007-2009 produces at -1 day
from the standard. So other days are also wrong. It is always November.
The other months work fine.



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


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

Reply via email to