Req #51447 [NEW]: strtotime(february) returns a date in march after march 28/29

From: Date: Wed, 31 Mar 2010 15:26:37 +0000
Subject: Req #51447 [NEW]: strtotime(february) returns a date in march after march 28/29
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-149231@lists.php.net to get a copy of this message
From: Operating system: PHP version: 5.3.2 Package: Date/time related Bug Type: Feature/Change Request Bug description:strtotime(february) returns a date in march after march 28/29 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 bug report at http://bugs.php.net/bug.php?id=51447&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51447&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51447&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51447&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51447&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51447&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51447&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51447&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51447&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51447&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51447&r=support Expected behavior: http://bugs.php.net/fix.php?id=51447&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51447&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51447&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51447&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51447&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51447&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51447&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51447&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51447&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51447&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51447&r=mysqlcfg

« previous php.bugs (#149231) next »