ID: 41335 Updated by: [EMAIL PROTECTED] Reported By: daniel dot oconnor at gmail dot com Status: Open -Bug Type: Date/time related +Bug Type: Feature/Change Request Operating System: All PHP Version: 5.2.2 -Assigned To: +Assigned To: derick New Comment:
Using / here is problematic as it's also the separator in use by the US folks, but then in the opposite way. Providing a configuration parameter won't work as the parser would not be able to handle that. As it's deliberately not working it is not a bug, but a feature request. It would be possible to allow parsing according to a given format but that would be totally new functionality which could make it into PHP 6. Previous Comments: ------------------------------------------------------------------------ [2007-05-09 02:37:27] daniel dot oconnor at gmail dot com Description: ------------ Australians tend to do dates in dd/mm/yyyy format, rather than mm/dd/yyyy strtotime cannot handle this when the seperator is a '/', but can for '-' and '.' PHP should either: * Use consistent parsing all the way through. It should not matter if I pick a '-', '/' or '.' * Provide me an argument or configuration setting with which I can change the default behaviour. See http://en.wikipedia.org/wiki/Calendar_date#Date_format for a list of countries which use dd/mm/yyyy as a default, compared to a list of those who use mm/dd/yyyy. Reproduce code: --------------- <?php print phpversion() . "\n\n"; $times = array(); $times[] = '1-10-2007'; $times[] = '1/10/2007'; $times[] = '1.10.2007'; $times[] = '13-10-2007'; $times[] = '13/10/2007'; $times[] = '13.10.2007'; $times[] = '2007-10-10'; $times[] = '2007/10/10'; $times[] = '2007.10.10'; $times[] = '13-13-2007'; $times[] = '13/13/2007'; $times[] = '13.13.2007'; foreach ($times as $time) { print $time ."\n\t" . strtotime($time) . "\n\t" . date('Y-m-d H:i:sa', strtotime($time)) . "\n\n"; } Expected result: ---------------- ---------- php ---------- 5.2.2 1-10-2007 1191196800 2007-10-01 00:00:00am 1/10/2007 1168387200 2007-01-10 00:00:00am 1.10.2007 1191196800 2007-10-01 00:00:00am 13-10-2007 1192233600 2007-10-13 00:00:00am 13/10/2007 1192233600 2007-10-13 00:00:00am 13.10.2007 1192233600 2007-10-13 00:00:00am 2007-10-10 1191974400 2007-10-10 00:00:00am 2007/10/10 1191974400 2007-10-10 00:00:00am 2007.10.10 1970-01-01 00:00:00am 13-13-2007 1970-01-01 00:00:00am 13/13/2007 1970-01-01 00:00:00am 13.13.2007 1970-01-01 00:00:00am Output completed (0 sec consumed) - Normal Termination Actual result: -------------- ---------- php ---------- 5.2.2 1-10-2007 1191196800 2007-10-01 00:00:00am 1/10/2007 1168387200 2007-01-10 00:00:00am 1.10.2007 1191196800 2007-10-01 00:00:00am 13-10-2007 1192233600 2007-10-13 00:00:00am 13/10/2007 1970-01-01 00:00:00am 13.10.2007 1192233600 2007-10-13 00:00:00am 2007-10-10 1191974400 2007-10-10 00:00:00am 2007/10/10 1191974400 2007-10-10 00:00:00am 2007.10.10 1970-01-01 00:00:00am 13-13-2007 1970-01-01 00:00:00am 13/13/2007 1970-01-01 00:00:00am 13.13.2007 1970-01-01 00:00:00am Output completed (0 sec consumed) - Normal Termination ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41335&edit=1
