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

 ID:                 54185
 Updated by:         der...@php.net
 Reported by:        chris at sternal-johnson dot com
 Summary:            strtotime misinterprets dates in format "1 Aug,
                     2005" for the 2000s
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Date/time related
 Operating System:   Ubuntu 10.10 Server
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is a tricky one, but not a bug.



2 Mar, 2008 is interpreted as "March 2nd, 20:08".

1999 is not a valid time, and as a fallback it will then be used as a
year:



derick@whisky:~$ pe 5.3dev

derick@whisky:~$ php -r 'print_r(date_parse("2 Mar, 2008"));'

Array

(

    [year] => 

    [month] => 3

    [day] => 2

    [hour] => 20

    [minute] => 8

    [second] => 0

    [fraction] => 

    [warning_count] => 0

    [warnings] => Array

        (

        )



    [error_count] => 0

    [errors] => Array

        (

        )



    [is_localtime] => 

)

derick@whisky:~$ php -r 'print_r(date_parse("2 Mar, 1999"));'

Array

(

    [year] => 1999

    [month] => 3

    [day] => 2

    [hour] => 

    [minute] => 

    [second] => 

    [fraction] => 

    [warning_count] => 0

    [warnings] => Array

        (

        )



    [error_count] => 0

    [errors] => Array

        (

        )



    [is_localtime] => 

)


Previous Comments:
------------------------------------------------------------------------
[2011-03-07 18:57:20] chris at sternal-johnson dot com

Description:
------------
It appears that strtotime misinterprets dates in formats like "1 Aug,
2005" or "2 

Mar, 2008" for the 2000s. Dates in 1900s are unaffected. The month and
day values 

are correctly interpreted, but the year is being set to the current
instead of the 

correct value.

Test script:
---------------
strtotime('2 Mar, 2008');<br />

<?php print strtotime('2 Mar, 2008')?><br />

<br />

strtotime('2 Mar 2008');<br />

<?php print strtotime('2 Mar 2008')?><br />

<br />

strtotime('2 Mar, 1999');<br />

<?php print strtotime('2 Mar, 1999')?><br />

<br />

strtotime('2 Mar 1999');<br />

<?php print strtotime('2 Mar 1999')?><br />

Expected result:
----------------
strtotime should generate the same date for '2 Mar, 2008' as '2 Mar
2008'.

Actual result:
--------------
strtotime wrongly generates 1299114480 (2 Mar 2011) for '2 Mar, 2008'
but 

correctly interprets 1204434000 for '2 Mar 2008'.




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



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

Reply via email to