Location: PHPKode > projects > H-tracker > blocks/calendar_block.php
<?php

$today_word = "Today";

list($today, $month, $year) = explode("-", date("j-m-Y"));

$day = mktime(0, 0, 0, $month, 1, $year);
$dayofweek = date("w", $day);
$back = ($dayofweek + 6) % 7;
$day -= 86400 * $back;
$day_tmp = $day;

$month_name = date("F");
begin_block("Calendar");
echo'<table align="center" border="0" cellpadding="3" cellspacing="0" class="clborder" width="100%">
<thead><tr>
	<td colspan="7" style="border-bottom: 0px; text-align: left;"><strong>ยป '.$month_name." ".date("Y").'</strong></td>
</tr><tr>';

for ($i=0; $i<7; $i++) {
	echo'<td class="colhead">'.substr(date('D', $day_tmp), 0, 1).'</td>';
	$day_tmp += 86400;
}

echo'</tr></thead>
<tbody>';

while (true) {
    echo'<tr>';
    for ($i=0; $i<7; $i++) {
		list($date, $month_tmp) = explode("-", date("j-m", $day));
		echo'<td';

		if ($today == $date && $month_tmp == date("m"))
			echo' class="cl3" title="'.$today_word.'"';
		elseif ($month != $month_tmp)
			echo' class="cl2"';
		else
			echo' class="cl1"';

		echo'>'.$date.'</td>';
		$day += 86400;
    }
    echo'</tr>';

    if ($month != $month_tmp)
		break;
}
echo'</tbody></table>';
end_block();

?>
Return current item: H-tracker