Aqui te pongo un script con el que puedes hacer un calendario para mostrar un listado de actividades, fechas importantes o lo que quieras, las aplicaciones practicas son bastantes y puedes mejorarlo como mas te convenga.
function make_calendar() { $html = ''; $now = getdate(time()); $time = mktime(0,0,0, $now['mon'], 1, $now['year']); $date = getdate($time); $dayTotal = cal_days_in_month(0, $date['mon'], $date['year']); $html.= '<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td colspan="7"><strong>' . $date['month'] . '</strong></td></tr>'; for ($i = 0; $i < 6; $i++) { $html.= '<tr>'; for ($j = 1; $j <= 7; $j++) { $dayNum = $j + $i*7 - $date['wday']; $html.= '<td'; if ($dayNum > 0 && $dayNum <= $dayTotal) { $html.= ($dayNum == $now['mday']) ? ' style="background: #ccc;">' : '>'; $html.= $dayNum; } else { $html.= '>'; } $html.= '</td>'; } $html.= '</tr>'; if ($dayNum >= $dayTotal && $i != 6) { break; } } $html.= '</table>'; return $html; }
Como usarlo:
echo make_calendar();