Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6906717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:20:45+00:00 2026-05-27T08:20:45+00:00

been looking at this for a bit and now my eyes are crossed. :)

  • 0

been looking at this for a bit and now my eyes are crossed. 🙂

I have a calendar script that I found on snipplr.com It’s pretty sweet. Props to the creators. Now, I have two things I want to customize.

Right now, the calendar spits out 12 months, January to December. And also the week ends on Sunday (grrrr). I am attempting to make it go from THIS MONTH, plus x number of months. For example, it would display December, plus 5 more months, so Dec, Jan, Feb, March, April, May.

I can tell in the code it uses a $i iteration to get through the months and display the appropriate dates. for($i=1;$i<=11;$i++)

SO, I tried changint it to this: for($i=$this_month;$i<=11;$i++)
$this_month of course being the date(‘m’);

It does successfully display December, but no months after it. (Since it stops at 11). But if I up the 11 to another variable of $this_month+5, then the script doesnt know what months 13, 14 and 15 are.

Any help on this one? Here is the entire script I have thusfar.

function days_in_month($month, $year) {
    if($month!=2) {
        if($month==9||$month==4||$month==6||$month==11)
            return 30;
        else
            return 31;
    }
    else
        return $year%4==""&&$year%100!="" ? 29 : 28;
}

global $months;
$months = array(0 => 'January', 1 => 'February', 2 => 'March', 3 => 'April', 4 => 'May', 5 => 'June', 6 => 'July', 7 => 'August', 8 => 'September', 9 => 'October', 10 => 'November', 11 => 'December');
$days = array(0 => 'Monday', 1 => 'Tuesday', 2 => 'Wednesday', 3 => 'Thursday', 4 => 'Friday', 5 => 'Saturday', 6 => 'Sunday');

function render_calendar($this_year = null) {
    if($this_year==null)
        $this_month = date('m')-1;
        $first = strtotime(date('m'));
        $last = strtotime("+6 months", $this_month);
        $this_year = date('Y');

    $day_of_the_month = date('N', strtotime('1 January '.$this_year));
    for($i=$this_month;$i<=12;$i++) {

//      echo $i;
//      if ($i==12) {
//          $i = 0;
//      }
        echo $i;
        echo "<table>
            <caption>".$GLOBALS['months'][$i]."</caption>
            <thead>
                <tr>
                    <th>Sun</th>
                    <th>Mon</th>
                    <th>Tue</th>
                    <th>Wed</th>
                    <th>Thu</th>
                    <th>Fri</th>
                    <th>Sat</th>

                </tr>
            </thead>
            <tbody>
                <tr>";
        for($n=1;$n<$day_of_the_month;$n++)
            echo "<td></td>\n";
        $days = days_in_month($i+1, $this_year);
        $day = 0;       
        while($day<$days) {
            if($day_of_the_month==8) {
                echo ($day == 0 ? "" : "</tr>\n") . "<tr>\n";
                $day_of_the_month = 1;
            }
            echo "<td style=\"border: 1px solid red;\">" . ($day+1) . "</td>\n";
            $day_of_the_month++;
            $day++;
        }
        echo "</tr>
            </tbody>
        </table>";
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:20:45+00:00Added an answer on May 27, 2026 at 8:20 am

    How about this for your loop:

    for($i=$this_month;$i<=$this_month+5;$i++) {
        // create a variable to hold the proper month index
        $currentMonth = $i;
        if ($i>11) {
            $currentMonth -= 12;
        }
        // now replace all references to the $i index with $currentMonth
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have been looking into this for a bit now and have become stuck.
Greetings. I have been looking at Literate Programming a bit now, and I do
This is a bit of a vague question I realise, but I've been looking
I have been looking at this for to long so I am tossing it
I've been looking for this, but can't find the answer. I have an NSMutableArray
I have been looking over this code for the past hour, I cant see
I've been looking into this issue for 2 days, but no luck. I have
I've been looking into this for a while now. I'm trying to put a
I have been looking for an answer to this on Stack Overflow, but I
I've been looking through RegEx help for a bit now but I think I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.