Bug #65623 [Opn->Nab]: BC change: strtotime() returns non-false for certain integer input values
Edit report at https://bugs.php.net/bug.php?id=65623&edit=1
ID: 65623
Updated by: derick@php.net
Reported by: mfischer@php.net
Summary: BC change: strtotime() returns non-false for certain
integer input values
-Status: Open
+Status: Not a bug
Type: Bug
Package: Date/time related
Operating System: Linux
PHP Version: 5.4.19
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 working as it should. strtotime() wants a *string* and not an integer. It's just
interpreted differently than you expect now:
derick@whisky:~ $ php -r 'var_dump(date_parse(1359367000));'
array(12) {
'year' =>
int(7000)
'month' =>
bool(false)
'day' =>
bool(false)
'hour' =>
int(13)
'minute' =>
int(59)
'second' =>
int(36)
'fraction' =>
double(0)
'warning_count' =>
int(0)
'warnings' =>
array(0) {
}
'error_count' =>
int(0)
'errors' =>
array(0) {
}
'is_localtime' =>
bool(false)
}
Instead of parsing a unix timestamp with strtotime(), you should just use the timestamp.
Previous Comments:
------------------------------------------------------------------------
[2013-09-05 14:20:19] mfischer@php.net
Description:
------------
strtotime() is described as "Parse about any English textual datetime description into a Unix
timestamp".
In my case I was providing an integer to $time (maybe it's considered "undefined"
behavior) and observed the following behavior: for certain integer input values, it stopped returned
false but actually returned value for a time.
Test script:
---------------
<?php
var_dump(strtotime(1359366999));
var_dump(strtotime(1359367000));
Expected result:
----------------
bool(false)
bool(false)
Actual result:
--------------
bool(false)
int(190309870776)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65623&edit=1
Thread (2 messages)