Hello guys I'm building with my calendar.
I'm trying to get the pre and post day of the current month for my calendar. Actually the calendar is already working but its not the same with the time with my laptop.
Do I have to change something in this code?
$month = 9;
$year = 2013;
// calculate the number of days in the current month
$day_count = cal_days_in_month(CAL_GREGORIAN, $month, $year);
// get number of days for the next month
$pre_days = (6 - (date('w', mktime(0, 0, 0, $month, $day_count, $year))));
// get number of days after the month
$post_days = date('w', mktime(0, 0, 0, $month, 1, $year));
Then I'm making a loop to display the dates..
echo "<div id='cal_wrapper'>";
echo "<div class='title_bar'>";
echo "<div class='prev_month'></div>";
echo "<div class='show_month'></div>";
echo "<div class='next_month'></div>";
echo "</div>"; // end title bar
echo "<div class='week_days'>";
foreach($weekDaysArr as $value)
{
echo "<div class='days_of_week'>".$value."</div>";
}
echo "<div class='clear'></div>";
echo "</div>"; // end week days
// Previous Month Filler
if($pre_days != 0) {
for($i = 1; $i <= $pre_days; $i++)
{
echo "<div class='non_cal_days'></div>";
}
}
// Current day of the month filler
if($day_count != 0 )
{
for($x = 1; $x <= $day_count; $x++)
{
echo "<div class='cal_days'>";
echo "<div class='day_header'>".$x."</div>";
echo "</div>";
}
}
// Current day of the month filler
if($post_days != 0 )
{
for($y = 1; $y <= $post_days; $y++)
{
echo "<div class='non_cal_days'></div>";
}
}
echo "</div>"; // end calendar wrapper