Possible Leap Year bug with strtotime (4.3.4)?
| From: | Rob Petty | Date: | Sat, 28 Feb 2004 22:44:45 +0000 |
| Subject: | Possible Leap Year bug with strtotime (4.3.4)? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179101@lists.php.net to get a copy of this message | ||
I am getting incorrect results from strtotime:
[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
[dali]$ cat t1.php
<?
$start = strtotime('next monday');
echo ('Start timestamp: '.$start.'<br>'."\n");
echo ('"Next" Monday: '.date('l, M d
Y',$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");
?>
[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]$
"next monday" should be Mar 01 2004 instead of Mar 08 2004. Any ideas?