From:             pettyr at hotmail dot com
Operating system: Linux
PHP version:      4.3.4
PHP Bug Type:     Date/time related
Bug description:  possible leap year strtotime hiccup

Description:
------------
The clients server is hosted by a third party running debian SMP Apache
and PHP 4.3.4.  The use of strtotime("next monday") skips monday the 1st
and returns monday the 8th when run on Feb. 28th (tomorrow is a leap
day.)



The servers particulars:

[dali]$ uname -a

Linux dali 2.4.24-grsec+w+fhs5+gr1913+nfs+++p3+c3+bu+gr0b-v6.182 #1 SMP
Mon Jan 5 12:43:44 PST 2004 i686 unknown

[dali]$ date

Sat Feb 28 14:33:39 PST 2004

Reproduce code:
---------------
[dali]$ cat t1.php

<?

$start = strtotime('next monday');

echo ('Start timestamp: '.$start.'<br>'."\n");

$first = strtotime('first Monday',$start);

echo ('"First" Monday: '.date('l, M d Y',$first).'<br>'."\n");

$oneth = strtotime('1 Monday',$start);

echo ('"1" Monday: '.date('l, M d Y',$oneth).'<br>'."\n");

$next = strtotime('next Monday',$start);

echo ('"Next" Monday: '.date('l, M d Y',$next).'<br>'."\n");

$twoth = strtotime('2 Monday',$start);

echo ('"2" Monday: '.date('l, M d Y',$twoth).'<br>'."\n");

$third = strtotime('third Monday',$start);

echo ('"Third" Monday: '.date('l, M d Y',$third).'<br>'."\n");

$threeth = strtotime('3 Monday',$start);

echo ('"3" Monday: '.date('l, M d Y',$threeth).'<br>'."\n");

?>

Expected result:
----------------
[dali]$ php t1.php

Content-type: text/html

X-Powered-By: PHP/4.3.4



Start timestamp: 1078732800<br>

"Next" Monday: Monday, Mar 01 2004<br>

"First" Monday: Monday, Mar 01 2004<br>

"1" Monday: Monday, Mar 01 2004<br>

"Next" Monday: Monday, Mar 08 2004<br>

"2" Monday: Monday, Mar 08 2004<br>

"Third" Monday: Monday, Mar 15 2004<br>

"3" Monday: Monday, Mar 15 2004<br>

[dali]$ 





Actual result:
--------------
[dali]$ php t1.php

Content-type: text/html

X-Powered-By: PHP/4.3.4



Start timestamp: 1078732800<br>

"Next" Monday: Monday, Mar 08 2004<br>

"First" Monday: Monday, Mar 08 2004<br>

"1" Monday: Monday, Mar 08 2004<br>

"Next" Monday: Monday, Mar 15 2004<br>

"2" Monday: Monday, Mar 15 2004<br>

"Third" Monday: Monday, Mar 22 2004<br>

"3" Monday: Monday, Mar 22 2004<br>

[dali]$ 









But, the exact same code run from my system:



[EMAIL PROTECTED] tmp]# uname -a

Linux helios 2.4.20-28.7smp #1 SMP Thu Dec 18 11:18:31 EST 2003 i686
unknown

[EMAIL PROTECTED] tmp]# date

Sat Feb 28 13:34:08 MST 2004

[EMAIL PROTECTED] tmp]# php /tmp/t1.php

X-Powered-By: PHP/4.1.2

Content-type: text/html



Start timestamp: 1078124400<br>

"Next" Monday: Monday, Mar 01 2004<br>

"First" Monday: Monday, Mar 01 2004<br>

"1" Monday: Monday, Mar 01 2004<br>

"Next" Monday: Monday, Mar 01 2004<br>

"2" Monday: Monday, Mar 08 2004<br>

"Third" Monday: Monday, Mar 15 2004<br>

"3" Monday: Monday, Mar 15 2004<br>



May be related to:

Bug #18670 strtotime() bug 

Submitted: 31 Jul 2002 10:26am EDT Modified: 18 Oct 2003 10:57pm EDT 



-- 
Edit bug report at http://bugs.php.net/?id=27431&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27431&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27431&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27431&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27431&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27431&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27431&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27431&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27431&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27431&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27431&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27431&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27431&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27431&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27431&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27431&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27431&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27431&r=float

Reply via email to