Re: Dynamic Date List Newbie Problem
| From: | revDAVE | Date: | Thu, 12 Mar 2009 21:29:22 +0000 |
| Subject: | Re: Dynamic Date List Newbie Problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289966@lists.php.net to get a copy of this message | ||
On 3/12/2009 12:25 PM, "Paul M Foster" <paulf@quillandmouse.com> wrote:
> Crap, I hit the wrong button and sent this only to the OP...
>
> On Thu, Mar 12, 2009 at 09:24:48AM -0700, revDAVE wrote:
>
Thanks for your help Paul - that makes sense!
>
> Here is working code to do it better:
>
> // get your starting date
> $darray = getdate();
> $month = $darray['mon'];
> $year = $darray['year'];
>
> // create your months
> $dt = array();
> for ($i = $month; $i >= 1; $i--) {
> $dt[] = date('m/d/y', mktime(0, 0, 0, $i, 1, $year));
> }
>
> $year--;
> for ($i = 12; $i > $month; $i--) {
> $dt[] = date('m/d/y', mktime(0, 0, 0, $i, 1, $year));
> }
>
> // print the dates, just as a check
> for ($i = 0; $i < count($dt); $i++) {
> print $dt[$i] . "<br>\n";
> }
>
> This gives you a decending array from the current 1st of the month to
> twelve months prior. The $dt array has mm/dd/yy date strings in it.
> Change as needed.
>
> Paul
--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]