Bug #52123 [Bgs]: strtotim() returns date for one year ago
Edit report at http://bugs.php.net/bug.php?id=52123&edit=1
ID: 52123
Updated by: derick@php.net
Reported by: alipendashteh at gmail dot com
Summary: strtotim() returns date for one year ago
Status: Bogus
Type: Bug
Package: Date/time related
Operating System: Windows
PHP Version: 5.3.2
New Comment:
Perhaps, but we can't just change how the parser works. Others might
perhaps rely on this.
Previous Comments:
------------------------------------------------------------------------
[2010-06-19 13:10:44] alipendashteh at gmail dot com
Yes; but I meant the default behavior of strtotime() is not appropriate
now.
and i think it is absolutely better that something like "2011, February
8" parses as "Y, F j" instead of "Hi, F j".
------------------------------------------------------------------------
[2010-06-19 13:03:52] degeberg@php.net
You already have DateTime::createFromFormat() if you wish to parse other
formats.
------------------------------------------------------------------------
[2010-06-19 12:59:36] alipendashteh at gmail dot com
you right; this is not a bug.
but i think the "Y, F j" is much more common than "Hi, F j".
and many application like Drupal use "Y, F j" as a default date format.
so parsing date as "Hi, F j" rather than "Y, F j" would cause confiusing
errors in applications.
I suggest replace the priorities of two format mentioned.
------------------------------------------------------------------------
[2010-06-19 11:41:47] derick@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
This is not a bug. 2011 is seen as time instead:
php -r 'var_dump(date_parse("2011, February 8"));'
array(12) {
["year"]=>
bool(false)
["month"]=>
int(2)
["day"]=>
int(8)
["hour"]=>
int(20)
["minute"]=>
int(11)
["second"]=>
int(0)
["fraction"]=>
bool(false)
["warning_count"]=>
int(0)
["warnings"]=>
array(0) {
}
["error_count"]=>
int(0)
["errors"]=>
array(0) {
}
["is_localtime"]=>
bool(false)
}
------------------------------------------------------------------------
[2010-06-19 11:22:14] alipendashteh at gmail dot com
Description:
------------
Hi,
strtotime returns wrong date (one year ago) with some formats like:
2011, February 8
Test script:
---------------
echo (date('Y-m-d', strtotime("2011, February 8")));
Expected result:
----------------
2011-02-08
Actual result:
--------------
2010-02-08
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52123&edit=1
Thread (6 messages)