ID:               18670
 Comment by:       sergio at wgo dot com dot br
 Reported By:      nic at bbmcarlson dot com
 Status:           Open
 Bug Type:         Date/time related
 Operating System: Linux
 PHP Version:      4.3.3RC5-dev
 New Comment:

I have a problem to use StrToTime with the date 2003-10-12. Its return
-1.

I'm using the version PHP 4.3.2

<?
$data10 = '2003-10-11';
$data11 = '10/11/2003';

## bug date
$data20 = '2003-10-12';  
$data21 = '10/12/2003';  

$data30 = '2003-10-13';
$data31 = '10/13/2003';

Echo Date( 'd-m-Y', StrToTime( $data10 ) )."<br>";
Echo Date( 'd-m-Y', StrToTime( $data11 ) )."<br>";
Echo StrToTime( $data11 )."<br>";

Echo Date( 'd-m-Y', StrToTime( $data20 ) )." ** on my server, display
'31-12-1969'...BUG or What ? <br>";
Echo Date( 'd-m-Y', StrToTime( $data21 ) )." ** on my server, display
'31-12-1969'...BUG or What ? <br>";
Echo StrToTime( $data21 )." display -1 <br>";

Echo Date( 'd-m-Y', StrToTime( $data30 ) )."<br>";
Echo Date( 'd-m-Y', StrToTime( $data31 ) )."<br>";
Echo StrToTime( $data31 )."<br>";

?>


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

[2003-02-11 14:12:37] mphillips at lufkin dot org

I have noticed that when you do something like
$sdate = date9'Y-m-d', strtotime('02-09-2003'));

$sdate is getting '2008-02-24'.

Is this a common occurance

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

[2002-10-31 12:07:20] matt at codewalkers dot com

I also can confirm that strtotime acts funny when the same day does not
exist in the next month:

<?
$timestamp = strtotime("31 October 2002");

$next_month = strftime("%B" ,strtotime("+1 month", $timestamp));

echo $next_month;
?>

displays:

December

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

[2002-09-24 17:07:42] spud at nothingness dot org

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>');
?>

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

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

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

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