Re: Dynamic Date List Newbie Problem

From: Date: Thu, 12 Mar 2009 21:27:38 +0000
Subject: Re: Dynamic Date List Newbie Problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-289965@lists.php.net to get a copy of this message
On 3/12/2009 9:39 AM, "TG" <tg-php@gryffyndevelopment.com> wrote: > $currmonth = date("m"); > > for ($i = 1; $i <= 11; $i++) { > $m[$i] = date("m/d/y"), mktime(0,0,0,$currmonth-$i, 1, 2009)); > } > > Something like that. mktime() is remarkably flexible. If you start on > month 3 and you subtract 5, you get month = -2. So that would be > -2/1/2009, which mktime will translate to 11/1/2008. > > This is totally off the top of my head, but you get the idea. Works with > days and years too. Sometimes it's useful when going backwards and not > sure how many days the previous month had (without doing another call to > find out). > > -TG SOLVED - Thanks so much Andrew & TG From your examples - I was able to create this working table going back 2 years - thanks again! ============ <table border="1" cellspacing="2" cellpadding="2"> <tr> <td>Dates</td> </tr> <?php $currmonth = date("m"); $curryear = date("y"); $i = 0; do { ?> <tr> <td><?php $m[$i] = date("m/d/y", mktime(0,0,0,$currmonth-$i, 1, $curryear)); echo $m[$i].'<br />'; $i++ ?> </td> </tr> <?php } while ($i < 25); ?> </table> -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09]

« previous php.general (#289965) next »