Exemplo n.º 1
0
if ($m == 1) {
    $previous_month = 12;
    $previous_year = $y - 1;
} else {
    $previous_month = $m - 1;
    $previous_year = $y;
}
if ($m == 12) {
    $next_month = 1;
    $next_year = $y + 1;
} else {
    $next_month = $m + 1;
    $next_year = $y;
}
$total_lastmonth = $cobj->total_days($previous_month, $previous_year);
$firstdate = $cdate->getDayOfWeek($y . "-" . $m . "-1");
//first date of month, 0 (for Sunday) through 6 (for Saturday)
if ($firstdate == $startDate) {
    //skip last month
    $startwrite = $total_lastmonth + 1;
} elseif ($firstdate < $startDate) {
    $startwrite = $total_lastmonth - (6 - ($startDate - $firstdate));
} else {
    $startwrite = $total_lastmonth - ($firstdate - $startDate - 1);
}
//--------------------------------
//prepare the calendar in array
//--------------------------------
$calendar_rows = array();
$week_rows = array();
//collection for week number, $week_rows[$row][$week_number] = counter