ID:               18670
 Comment by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
 Status:           Assigned
 Bug Type:         Date/time related
 Operating System: RedHat Linux Linux linux1 2.2.16
 PHP Version:      4.2.2
 Assigned To:      rasmus
 New Comment:

In PHP 4.2.3, the difference between "2" and "next" are still screwy in
strtotime(). I'm trying to parse icalendar recurrence formats, so I
need to calculate things like the "second Monday" in a month. Sample
code below illustrates the difference between "2" and "next" (which
should be identical).

<?
$start = strtotime('September 1, 2002');
echo ('Start timestamp: '.$start.'<br>');
echo ('Start date: Sunday, Sep 1 2002<br>');
$first = strtotime('first Monday',$start);
echo ('"First" Monday: '.date('l, M d Y',$first).'<br>');
$oneth = strtotime('1 Monday',$start);
echo ('"1" Monday: '.date('l, M d Y',$oneth).'<br>');
$next = strtotime('next Monday',$start);
echo ('"Next" Monday: '.date('l, M d Y',$next).'<br>');
$twoth = strtotime('2 Monday',$start);
echo ('"2" Monday: '.date('l, M d Y',$twoth).'<br>');
$third = strtotime('third Monday',$start);
echo ('"Third" Monday: '.date('l, M d Y',$third).'<br>');
$threeth = strtotime('3 Monday',$start);
echo ('"3" Monday: '.date('l, M d Y',$threeth).'<br>');
?>


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

[2002-07-31 18:07:05] [EMAIL PROTECTED]

Assigning to rasmus as it sounds like he already knows whats wrong.

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

[2002-07-31 10:51:09] [EMAIL PROTECTED]

so can we assign this bug to you Rasmus?

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

[2002-07-31 10:44:11] [EMAIL PROTECTED]

Sebastian, yes, that is because I changed how "next" works based on bug
report #18655

It works correctly for days now, but it does seem like month-handling
is messed up now.  

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

[2002-07-31 10:39:10] [EMAIL PROTECTED]

The problem is that it adds a full month to the current timestamp.  So
you end up getting the 31st of the next month and some months do not
have 31 days.  I'll need to do some reading to determine if strtotime()
is supposed to pick the beginning of the next month instead, or perhaps
the middle.

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

[2002-07-31 10:38:50] [EMAIL PROTECTED]

Strange... With PHP4.3.0-dev-200207300000 on Compaq Tru64 the output is
"July October December".

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

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/18670

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

Reply via email to