note 103584 added to function.date
| From: | johnedwarddoyle at googlemail dot com | Date: | Thu, 21 Apr 2011 09:23:35 +0000 |
| Subject: | note 103584 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179039@lists.php.net to get a copy of this message | ||
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));
}
?>
----
Server IP: 87.124.126.137
Probable Submitter: 92.27.86.226 (proxied: 92.27.86.226)
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/103584
Del: integrated -- https://master.php.net/note/delete/103584/integrated
Del: useless -- https://master.php.net/note/delete/103584/useless
Del: bad code -- https://master.php.net/note/delete/103584/bad+code
Del: spam -- https://master.php.net/note/delete/103584/spam
Del: non-english -- https://master.php.net/note/delete/103584/non-english
Del: in docs -- https://master.php.net/note/delete/103584/in+docs
Del: other reasons-- https://master.php.net/note/delete/103584
Reject -- https://master.php.net/note/reject/103584
Search -- https://master.php.net/manage/user-notes.php