note 85626 added to function.strtotime
| From: | corey1981 at gmail dot com | Date: | Tue, 09 Sep 2008 18:30:03 +0000 |
| Subject: | note 85626 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144268@lists.php.net to get a copy of this message | ||
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?
----
Server IP: 69.147.83.197
Probable Submitter: 74.138.173.43
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/85626
Del: integrated -- https://master.php.net/note/delete/85626/integrated
Del: useless -- https://master.php.net/note/delete/85626/useless
Del: bad code -- https://master.php.net/note/delete/85626/bad+code
Del: spam -- https://master.php.net/note/delete/85626/spam
Del: non-english -- https://master.php.net/note/delete/85626/non-english
Del: in docs -- https://master.php.net/note/delete/85626/in+docs
Del: other reasons-- https://master.php.net/note/delete/85626
Reject -- https://master.php.net/note/reject/85626
Search -- https://master.php.net/manage/user-notes.php