How to ouput the upcoming 6 months?

Discussion in 'PHP' started by krishmk, Jul 9, 2009.

  1. #1
    Ok I have the current code which shows the current month with Year.
    I need to show the next 6 months.

    <?php
    $date2 = time();
    $month = date('F', $date2);
    $year = date ('Y', $date2);
    echo ("$month - $year");
    ;?>
    PHP:
    Would appreciate your help....
    [I am already using a variable $date elsewhere in the same page thats why I have chose $date2]
     
    krishmk, Jul 9, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    
    
    $date2 = time();
    $month = date('F', $date2);
    $year = date ('Y', $date2);
    echo ("$month - $year");
    
    $months = 6;
    
    for($i=1;$i<=$months;$i++):
    
    $month = date('F',strtotime("+ ".$i." Months"));
    
    echo ("$month - $year");
    
    endfor;
    
    
    PHP:
     
    jestep, Jul 9, 2009 IP
    krishmk likes this.