Re: Dynamic Date List Newbie Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/12/2009 12:25 PM, "Paul M Foster" <paulf@xxxxxxxxxxxxxxxxx> 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]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux