ID: 43960 Updated by: [EMAIL PROTECTED] Reported By: chris dot corbyn at sitepoint dot com -Status: Assigned +Status: Closed Bug Type: Date/time related Operating System: OS X/Linux PHP Version: 5.2.5 Assigned To: derick New Comment:
This is in CVS now (or was for some weeks). Previous Comments: ------------------------------------------------------------------------ [2008-01-29 10:15:48] chris dot corbyn at sitepoint dot com Thanks for the detailed and useful explanation. Checking for more than two occurrences of timezone specification and returning false is such a scenario would be the way to go I agree. Thanks very much, Chris. ------------------------------------------------------------------------ [2008-01-29 07:31:52] [EMAIL PROTECTED] "I" is seen as a timezone (Like L or Z could be). There is thus nothing wrong with that specific string. However, in the first one the parser sees many different timezone strings, parsing with date_parse() shows: [EMAIL PROTECTED]:~/dev/php/php-5.3dev$ sapi/cli/php <?php var_dump(date_parse("i like to eat slices at work")); ?> array(16) { ["year"]=> bool(false) ["month"]=> bool(false) ["day"]=> bool(false) ["hour"]=> bool(false) ["minute"]=> bool(false) ["second"]=> bool(false) ["fraction"]=> bool(false) ["warning_count"]=> int(6) ["warnings"]=> array(6) { [2]=> string(29) "Double timezone specification" [7]=> string(29) "Double timezone specification" [10]=> string(29) "Double timezone specification" [14]=> string(29) "Double timezone specification" [21]=> string(29) "Double timezone specification" [24]=> string(29) "Double timezone specification" } ["error_count"]=> int(0) ["errors"]=> array(0) { } ["is_localtime"]=> bool(true) ["zone_type"]=> int(2) ["zone"]=> int(-540) ["is_dst"]=> bool(false) ["tz_abbr"]=> string(1) "I" } I don't know whether I can make a double timezone string an error, as it's common to use things like "GMT+04:00" which would trigger the same error then - while being a valid string. I think the most I can do if when it sees *more* than two timezones it turns it into errors. ------------------------------------------------------------------------ [2008-01-29 05:29:03] chris dot corbyn at sitepoint dot com Description: ------------ When writing a unit test to ensure bogus data cannot be passed to our e-commerce paypal request-response library we've stumbled upon an unexpected problem. I enjoy the occassional (1-2 per day) slice whilst at work so I passed this as a test bogus string. <?php var_dump(strtotime('i like to eat slices at work')); ?> This returns a timestamp exactly 2 hours in the future. This has been tested on 2 different macs and a linux server. We've pinned it down to the "i". What we really expected was a boolean false return value. Reproduce code: --------------- <?php var_dump(strtotime('i like to eat slices at work')); var_dump(strtotime('i')); //same ?> Expected result: ---------------- A boolean FALSE return is expected. Actual result: -------------- An integer representing a UNIX timestamp exactly 2 hours in the future is returned. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43960&edit=1