On 3/12/2009 9:39 AM, "TG" <tg-...@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]




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

Reply via email to