1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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.