SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display next 6Months in Text

    Hi Friends,

    I would like to display next 6 months in full text.

    $next_month = date("F", strtotime("+1 month"));
    echo $next_month;

    This code displays 'June' as next month.Here I am fine.

    Similarly,I wrote code like this to display next 6months in for loop.

    for($i=1;$i<6;$i++)
    {
    $months = date("F", strtotime("$i month"));
    echo $months[i];
    }

    This code displays J J A S O.But I want this to display June,July,August,September,October.

    Could anyone let me know how to display full text of next 6months.

    Thanks
    -Priya

  2. #2
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change $months[i] to $months.

  3. #3
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for($i=1;$i<6;$i++)
    {
    $months = date("F", strtotime("$i month"));
    echo $months;
    }

    $months is a string. and you are trying to print one characters and treating it as array.
    ---------------------------
    Errors = Improved Programming.
    My Site


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •