ID: 33546 Updated by: [EMAIL PROTECTED] Reported By: nickj-phpbugs at nickj dot org -Status: Wont fix +Status: Closed Bug Type: Date/time related Operating System: Debian Woody GNU/Linux 3.0r6 PHP Version: 5CVS-2005-07-02 (dev) Assigned To: derick New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2005-10-10 04:09:40] nickj-phpbugs at nickj dot org Fair enough. I only noticed this in passing, and wondered about it, but I understand your logic and I agree it's not worth making the code more brittle for this case, when people can instead just remove the day-of-the-week string to get the correct results. ------------------------------------------------------------------------ [2005-10-07 23:46:09] [EMAIL PROTECTED] We can not easily ignore weekday names in strings at arbitrary places in the way the current scanner works now. Changing it to allow for this means more more rigid formats are supported only, losing a lot of complexity in the code and less flexibility. ------------------------------------------------------------------------ [2005-07-02 10:33:33] nickj-phpbugs at nickj dot org Description: ------------ Should strtotime() ignore the weekday for some inputs, rather than treat it as a modifier? Example code: ================================================= <?php print "Should the weekday be treated as part of the time, rather than a modifier?\n"; $input = "Friday July 1 2005 10:00:00 AM"; print "input: " . $input . "\n"; $tStamp = strtotime($input); print "date : " . date ("l F j Y H:i:s A", $tStamp) . "\n\n"; print "Should the weekday be treated as part of the time, rather than a modifier?\n"; $input = "10:00:00 AM Friday July 1 2005"; print "input: " . $input . "\n"; $tStamp = strtotime($input); print "date : " . date ("H:i:s A l F j Y", $tStamp) . "\n"; ?> ================================================= Actual output: ================================================== G:\PHP bugs\php5-win32-200507020230>php.exe ..\weekday-as-time-not-modifier\weekday-as-time-not-modifier.php Should the weekday be treated as part of the time, rather than a modifier? input: Friday July 1 2005 10:00:00 AM date : Friday July 8 2005 10:00:00 AM Should the weekday be treated as part of the time, rather than a modifier? input: 10:00:00 AM Friday July 1 2005 date : 00:00:00 AM Friday July 8 2005 G:\PHP bugs\php5-win32-200507020230> ================================================== What I thought the output would be: ================================================== G:\PHP bugs\php5-win32-200507020230>php.exe ..\weekday-as-time-not-modifier\weekday-as-time-not-modifier.php Should the weekday be treated as part of the time, rather than a modifier? input: Friday July 1 2005 10:00:00 AM date : Friday July 1 2005 10:00:00 AM Should the weekday be treated as part of the time, rather than a modifier? input: 10:00:00 AM Friday July 1 2005 date : 10:00:00 AM Friday July 1 2005 G:\PHP bugs\php5-win32-200507020230> ================================================== Or, to put it another way: strtotime("Friday July 1 2005 10:00:00 AM") gives the same results as strtotime("10:00:00 AM", strtotime("Friday", strtotime("July 1 2005"))), when I would expect it to be equivalent to strtotime("10:00:00 AM", strtotime("July 1 2005")). Note: I'm not sure what I would expect to happen if the weekday was the wrong day (e.g. "Monday July 1 2005 10:00:00 AM"). I think maybe the least surprising thing would be if the weekday was always ignored for these two formats (since it's redundant as it can be determined from the date anyway), same as if the input had been "July 1 2005 10:00:00 AM". And if someone really did then want to use the "Monday" modifier, they could just use strtotime("Monday", strtotime("July 1 2005 10:00:00 AM")) to achieve this. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33546&edit=1