I picked up this script quite a while ago. It is a simple calendar script. It works really good except for the month of December. Can anyone see why the day is off on the month of December.
I appreciate your time.
Thanks
if($calendar_size == "small")
{
$WeekDayArray = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
} else {
$WeekDayArray = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
}
//check for the requested month, if none default to current
if(!isset($_GET["month"])){
$intMonth = Date("n");
} else {
$intMonth = $_GET["month"];
}
//check for the requested year, if none default to current
if(!isset($_GET["year"]))
{
$intYear = Date("Y");
} else {
$intYear = $_GET["year"];
}
$dtmTemp = 0;
$intDays = 0;
$intWeekDay = 0;
$intOffset = 0;
$dtmTemp = Date("m-d-Y",mktime(0,0,0,$intMonth % 12 + 1, 1, $intYear,-1));
$intDays = Date("t",mktime(0,0,0,$intMonth % 12 , 1, $intYear));
$intWeekDay = Date("w", mktime(0,0,0,$intMonth %12, 1, $intYear,-1)) + 1;
$intOffset = Date("w", mktime(0,0,0,$intMonth %12 , 1, $intYear,-1));
?>
<table border='1' cellpadding='5' cellspacing='0' bgcolor="#cccccc">
<tr>
<td align='left' valign="top">
<table width='100%' border='0' cellpadding='5' cellspacing='0'>
<tr>
<td align='left'>
<a href='<?=$_SERVER['PHP_SELF']?>?month=<?php echo ($intMonth+10)%12+1 ?>&year=<?php echo (($intMonth+10)%12+1 == 12 ? $intYear-1:$intYear) ?>'>PREV</a>
<a href='<?=$_SERVER['PHP_SELF']?>?month=<?php echo $intMonth%12+1 ?>&year=<?php echo ($intMonth%12+1 == 1 ? $intYear+1:$intYear) ?>'>NEXT</a>
</td>
<td align='right'>
<?php
echo "<font face='Arial' size='2' color='#000033'>";
echo Date("F", mktime(0,0,0,$intMonth % 12, 1, $intYear,-1))." $intYear";
echo "</font>";
echo " ";
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width='100%' height='100%' valign='top' >
<table align='left' width='100%' cellspacing='0' cellpadding='5' border="1" bgcolor="#ffffff">
<?php
for($i=0;$i < 7;$i++)
{
print "<td align='center' width='$cell_width'>";
print $WeekDayArray[$i];
print "</td>";
}
?>
</tr>
<?php
//$intEnd is the number of boxes we need to print to reach the end of the month
$intEnd = $intWeekDay + $intDays;
//We use 42 here cause a month can at most span 6 weeks.
for($x = 1;$x<=42;$x++)
{
//This gives us the number of the day of the month
$intCurrentDay = $x - $intOffset ;
//Mod by 7 to separate the weeks
if( $x%7 == 1)
{
print"<tr height='$cell_height'>";
}
//if we're within the current month print a box with the day, else print a gray box
if( $x >= $intWeekDay && $x < $intEnd)
{
print"<td valign='top'>";
echo " ".$intCurrentDay."<br>";
print"</td>";
} else {
print "<td valign='top'> </td>";
}
if( $x%7 == 0){
print"</tr>";
}
}
print"
</table>
</td>
</tr>
</table>
";