Edit report at https://bugs.php.net/bug.php?id=64369&edit=1
ID: 64369 Updated by: der...@php.net Reported by: gen dot work at gmail dot com Summary: strtotime() doesn't return false for some invalid formats Status: Not a bug Type: Bug Package: Date/time related Operating System: Ubuntu 12.10 PHP Version: 5.4.12 Block user comment: N Private report: N New Comment: "months" alone is a variant keyword for "month", so no. Previous Comments: ------------------------------------------------------------------------ [2013-03-06 15:28:32] gen dot work at gmail dot com Then following this logic '-1 months' should be parsed as 1 month + S, where S is a timezone abbreviation? ------------------------------------------------------------------------ [2013-03-06 14:30:26] der...@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 That is because they are not invalid. "Z" is a timezone abbreviation: derick@whisky:~ $ php -r 'var_dump(date_parse("-1 monthZ"));' array(17) { 'year' => bool(false) 'month' => bool(false) 'day' => bool(false) 'hour' => bool(false) 'minute' => bool(false) 'second' => bool(false) 'fraction' => bool(false) 'warning_count' => int(0) 'warnings' => array(0) { } 'error_count' => int(0) 'errors' => array(0) { } 'is_localtime' => bool(true) 'zone_type' => int(2) 'zone' => int(0) 'is_dst' => bool(false) 'tz_abbr' => string(1) "Z" 'relative' => array(6) { 'year' => int(0) 'month' => int(-1) 'day' => int(0) 'hour' => int(0) 'minute' => int(0) 'second' => int(0) } } And "SX" is (monthS + X), with X also be a timezone abbreviation: derick@whisky:~ $ php -r 'var_dump(date_parse("-1 monthsx"));' array(17) { 'year' => bool(false) 'month' => bool(false) 'day' => bool(false) 'hour' => bool(false) 'minute' => bool(false) 'second' => bool(false) 'fraction' => bool(false) 'warning_count' => int(0) 'warnings' => array(0) { } 'error_count' => int(0) 'errors' => array(0) { } 'is_localtime' => bool(true) 'zone_type' => int(2) 'zone' => int(660) 'is_dst' => bool(false) 'tz_abbr' => string(1) "X" 'relative' => array(6) { 'year' => int(0) 'month' => int(-1) 'day' => int(0) 'hour' => int(0) 'minute' => int(0) 'second' => int(0) } } ------------------------------------------------------------------------ [2013-03-06 13:47:17] gen dot work at gmail dot com Description: ------------ strtotime() doesn't return false for some invalid formats. Test script: --------------- var_dump(strtotime('invalid_string')); var_dump(strtotime('-1 monthZ')); var_dump(strtotime('-1 monthsx')); Expected result: ---------------- bool(false) bool(false) bool(false) Actual result: -------------- bool(false) int(1360161652) int(1360201252) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=64369&edit=1