note 103584 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Mon, 05 Sep 2011 13:02:26 +0000 |
| Subject: | note 103584 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-182951@lists.php.net to get a copy of this message | ||
Note Submitter: johnedwarddoyle at googlemail dot com
----
I was looking for a way to return a list of months between now and a previous month for use in a
select field. I came up with the following as I couldn't find anything else. There is
probably an easier way to do it, but this way was quite interesting.
<?php
$start=strtotime("01 January 2010");
$now=strtotime(date("d F Y"));
while($now>=$start)
{
echo "<option value=\"$now\">" . date('F Y', $now) .
"</option>\n";
$now=$now-(60*60*24*(365/12));
}
?>