Bug #74930 [Nab]: when $timestamp > 1500367000, strtotime($timestamp) won't return false

From: Date: Wed, 19 Jul 2017 07:16:23 +0000
Subject: Bug #74930 [Nab]: when $timestamp > 1500367000, strtotime($timestamp) won't return false
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-210129@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74930&edit=1 ID: 74930 Updated by: derick@php.net Reported by: yaozeyuan93 at gmail dot com Summary: when $timestamp > 1500367000, strtotime($timestamp) won't return false Status: Not a bug Type: Bug Package: Date/time related Operating System: Any PHP Version: 5.6.31 Block user comment: N Private report: N New Comment: And you can make it work by prefixing the @ in front of the number: strtotime("@1500367000"); Previous Comments: ------------------------------------------------------------------------ [2017-07-19 06:27:05] requinix@php.net Because 1500366999 looks like it fits the format YYYYdoy (year 1500, day of year 366) but is rejected due to the extra characters '999' at the end. https://3v4l.org/MsDGL I'll say it again: garbage in, garbage out. If strtotime has to try to make sense of something that is not a date string then you may get unexpected results. ------------------------------------------------------------------------ [2017-07-19 01:54:42] johnoflah at gmail dot com If it is looking for HHMMSSYYYY why would: strtotime("1500366999"); return false but: strtotime("1500367000"); return a timestamp? ------------------------------------------------------------------------ [2017-07-15 17:36:07] requinix@php.net 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 Because that number looks like HHMMSSYYYY format. http://php.net/manual/en/datetime.formats.php strtotime has to assume that what you pass is supposed to be a date/time string of some sorts. Garbage in, garbage out. ------------------------------------------------------------------------ [2017-07-15 17:29:20] yaozeyuan93 at gmail dot com Description: ------------ according to [document](http://php.net/manual/en/function.strtotime.php#refsect1-function.strtotime-changelog), put number into strtotime will be ignore and return false. But if the number > 1500367000, strtotime will return a big number but not false instead Test script: --------------- <?php $timestamp = 1500367000; // result by strtotime('2017-7-18 16:36:40'),larger will also had this problem echo strtotime($timestamp); // while return 158748447636, not false Actual result: -------------- 158748447636 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74930&edit=1

« previous php.bugs (#210129) next »