Edit report at http://bugs.php.net/bug.php?id=51447&edit=1
ID: 51447
User updated by: marques at displague dot com
Reported by: marques at displague dot com
Summary: strtotime(february) returns a date in march after march
28/29
Status: Open
Type: Feature/Change Request
Package: Date/time related
PHP Version: 5.3.2
New Comment:
Expected result:
[9] => Wed, 03 Mar 10 00:00:00 -0500
Should have read:
[9] => Sun, 28 Feb 10 00:00:00 -0500
I would also revise my "Example:" to show that:
- actual: date(DATE_RFC822,strtotime('june', strtotime("july 31 2010")))
yields
"...1 Jul 10.."
- expected: date(DATE_RFC822,strtotime('june', strtotime("july 31
2010")))
should yield "...30 Jun 10..."
Previous Comments:
------------------------------------------------------------------------
[2010-03-31 17:26:36] marques at displague dot com
Description:
------------
strtotime("february") gives erratic results based on the current day of
the
month
and whether or not that day number exists in February.
strtotime("february") should always return the current day as it is
found in
february, or the last day in february.
This is the case for any month where the current day number is not found
in the
requested month. The last day in a month should be returned if the
current day
is
not found in that month.
Example:
date(DATE_RFC822,strtotime('june', strtotime("july 31 2010"))) gives
July 1.
Bug #49115 points out this fact for "February" in the form of a bug
report.
This report shows that the problem exists for all months (with better
sample
cases) and I am requesting a change to the accepted behavior in favor of
something more sensible.
Test script:
---------------
date_default_timezone_set('America/New_York');
print_r(array(
date(DATE_RFC822,strtotime('february', strtotime("january 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("february 28 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("march 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("april 30 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("may 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("june 30 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("july 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("august 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("september 30
2010"))),
date(DATE_RFC822,strtotime('february', strtotime("october 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("november 30 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("december 31 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("january 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("february 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("march 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("april 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("may 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("june 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("july 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("august 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("september 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("october 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("november 1 2010"))),
date(DATE_RFC822,strtotime('february', strtotime("december 1 2010"))),
date(DATE_RFC822,strtotime('june', strtotime("july 31 2010"))),
));
Expected result:
----------------
Array
(
[0] => Sun, 28 Feb 10 00:00:00 -0500
[1] => Sun, 28 Feb 10 00:00:00 -0500
[2] => Sun, 28 Feb 10 00:00:00 -0500
[3] => Sun, 28 Feb 10 00:00:00 -0500
[4] => Sun, 28 Feb 10 00:00:00 -0500
[5] => Sun, 28 Feb 10 00:00:00 -0500
[6] => Sun, 28 Feb 10 00:00:00 -0500
[7] => Sun, 28 Feb 10 00:00:00 -0500
[8] => Sun, 28 Feb 10 00:00:00 -0500
[9] => Wed, 03 Mar 10 00:00:00 -0500
[10] => Sun, 28 Feb 10 00:00:00 -0500
[11] => Sun, 28 Feb 10 00:00:00 -0500
[12] => Mon, 01 Feb 10 00:00:00 -0500
[13] => Mon, 01 Feb 10 00:00:00 -0500
[14] => Mon, 01 Feb 10 00:00:00 -0500
[15] => Mon, 01 Feb 10 00:00:00 -0500
[16] => Mon, 01 Feb 10 00:00:00 -0500
[17] => Mon, 01 Feb 10 00:00:00 -0500
[18] => Mon, 01 Feb 10 00:00:00 -0500
[19] => Mon, 01 Feb 10 00:00:00 -0500
[20] => Mon, 01 Feb 10 00:00:00 -0500
[21] => Mon, 01 Feb 10 00:00:00 -0500
[22] => Mon, 01 Feb 10 00:00:00 -0500
[23] => Mon, 01 Feb 10 00:00:00 -0500
[24] => Wed, 30 Jun 10 00:00:00 -0400
)
Actual result:
--------------
Array
(
[0] => Wed, 03 Mar 10 00:00:00 -0500
[1] => Sun, 28 Feb 10 00:00:00 -0500
[2] => Wed, 03 Mar 10 00:00:00 -0500
[3] => Tue, 02 Mar 10 00:00:00 -0500
[4] => Wed, 03 Mar 10 00:00:00 -0500
[5] => Tue, 02 Mar 10 00:00:00 -0500
[6] => Wed, 03 Mar 10 00:00:00 -0500
[7] => Wed, 03 Mar 10 00:00:00 -0500
[8] => Tue, 02 Mar 10 00:00:00 -0500
[9] => Wed, 03 Mar 10 00:00:00 -0500
[10] => Tue, 02 Mar 10 00:00:00 -0500
[11] => Wed, 03 Mar 10 00:00:00 -0500
[12] => Mon, 01 Feb 10 00:00:00 -0500
[13] => Mon, 01 Feb 10 00:00:00 -0500
[14] => Mon, 01 Feb 10 00:00:00 -0500
[15] => Mon, 01 Feb 10 00:00:00 -0500
[16] => Mon, 01 Feb 10 00:00:00 -0500
[17] => Mon, 01 Feb 10 00:00:00 -0500
[18] => Mon, 01 Feb 10 00:00:00 -0500
[19] => Mon, 01 Feb 10 00:00:00 -0500
[20] => Mon, 01 Feb 10 00:00:00 -0500
[21] => Mon, 01 Feb 10 00:00:00 -0500
[22] => Mon, 01 Feb 10 00:00:00 -0500
[23] => Mon, 01 Feb 10 00:00:00 -0500
[24] => Thu, 01 Jul 10 00:00:00 -0400
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51447&edit=1