ID:               27634
 User updated by:  kingoleg at mail dot ru
 Reported By:      kingoleg at mail dot ru
-Status:           Bogus
+Status:           Open
 Bug Type:         Date/time related
 Operating System: All
-PHP Version:      4.3.4
+PHP Version:      4.3.4, 5CVS
 New Comment:

As I know, in php 4 and php 5 strtotime do support it. It's wrong.


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

[2004-03-24 04:28:16] kingoleg at corason dot ua

"Borders" of this bug:

'20040318094229'

'20040318094230'



Manual:

Because strtotime() behaves according to GNU date syntax, have a look
at the GNU manual page titled Date Input Formats. Described there is
valid syntax for the time parameter.



So, neither '20040318094229' nor '20040318094230' are both not valid
syntax for the time parameter. But...



Test result:



20040318094231







-1

79200

165600



Test source:

<?php

$date = '20040317';

$h = '00';

$i = '00';

$s = '00';

$t = -1;

while($t == -1) {

    $t = strtotime($date.$h.$i.$s);

    $s++;

    if (strlen($s) == 1) {

        $s = '0'.$s;

    }

    if ($s == 60) {

        $s = 0;

        $i++;

    }

    if (strlen($i) == 1) {

        $i = '0'.$i;

    }

    if ($i ==  60) {

        $i = 0;

        $h++;

    }

    if (strlen($h) == 1) {

        $h = '0'.$h;

    }

    if ($h == 24) {

        $h = 0;

        $date++;

    }

    if ($date == 20040319) {

        break;

    }

}

echo $date.$h.$i.$s;

echo '<br>';

echo '<br>';

echo '<br>';

echo '<br>';

echo strtotime('20040318094229');

echo '<br>';

echo strtotime('20040318094230');

echo '<br>';

echo strtotime('20040318094231');

?>



P.S. Sorry, I wrote "Actual result" as "Expected result".

P.P.S. Russian description of this bug is here
http://rsdn.ru/Forum/Message.aspx?mid=573729&only=1

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

[2004-03-18 11:12:46] [EMAIL PROTECTED]

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

strtotime doesn\'t support it.

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

[2004-03-18 11:02:34] kingoleg at mail dot ru

Description:
------------
strtotime() do not correct work with MySQL datetime(14).

Founded in Smarty shared.make_timestamp.php:



function smarty_make_timestamp($string)

{

//Skiped

    $time = strtotime($string);

//For date before 20040318000000 return -1

//After 20040318100000 return timestamp

    if (is_numeric($time) && $time != -1)

        return $time;



    // is mysql timestamp format of YYYYMMDDHHMMSS?

    if (preg_match('/^\d{14}$/', $string)) {

//Skiped

    }

}



Reproduce code:
---------------
Type this code:

<?php

$t = strtotime('20040318000000');

echo $t;

echo "<br>"

$t = strtotime('20040318100000');

echo $t;

?>



Expected result:
----------------
-1

149979600

Actual result:
--------------
-1

-1


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


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

Reply via email to