note 85626 rejected from function.strtotime by thiago
| From: | thiago@php.net | Date: | Wed, 10 Sep 2008 20:56:03 +0000 |
| Subject: | note 85626 rejected from function.strtotime by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144316@lists.php.net to get a copy of this message | ||
Note Submitter: corey1981 at gmail dot com
----
I was using some code to generate a list of 12 months before this month so in September, the list
looks like this:
* August 2008
* July 2008
* June 2008
* May 2008
* April 2008
* March 2008
* March 2008
* January 2008
* December 2007
* November 2007
* October 2007
* September 2007
* August 2007
using the code date('F Y',strtotime("$i month")) and substituting a negative
number for $i in a for loop. Well, when this code runs on the 30th of the month, February becomes
March, because there is no 30th of February, and on the 31st of a month, there are a whole lot of
months that don't work right.
So, what i did was calculate from the 15th of the current month and then subract months like this:
date('F Y',strtotime(date('Y-m-15')."$i month"))
So, my question is, why is strtotime doing it's subtraction in days instead of the actual
months that are referenced?