note 44554 deleted from ref.calendar by tomsommer
| From: | tomsommer@php.net | Date: | Mon, 09 Aug 2004 19:39:00 +0000 |
| Subject: | note 44554 deleted from ref.calendar by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74344@lists.php.net to get a copy of this message | ||
Note Submitter: miwaniec@lo7.wroc.pl
----
It's better version of calendar, sundays is on end of table
and month is as parametr of function.
I based on code by dindinha_debs at hotmail dot com
<?php
function calendar($month) {
$s=0;
// Get the calender info
$t_days = cal_days_in_month(CAL_GREGORIAN, (date("m",$month)),
date("Y",$month));
$day = date("w", mktime(0, 0, 0, date("m",$month), 1,
date("Y",$month)))-1;
if($day==-1) $day=6;
?>
<table border="0">
<tr><th bgcolor="yellow" colspan= "7">
<?=date("F Y",$month )?></th></tr>
<tr><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th>
<th>Fri</th><th>Sat</th><th>Sun</th></tr>
<?
for ($i = 0; $i <= $t_days; $i++) {
if ($day > 6) {
$s++;
echo "</tr>\n<tr>\n";
$day = 0;
}
//------------------------------------------------//
if ($i == date("j")) {
?><td align = "center"><b><?echo $i; $day++; echo
"</b></td>\n";
} else if ($i > 0) {
?><td align = "center"><?echo $i; $day++; echo
"</td>\n";
} else if ($day > 0) {
?><tr><td colspan = "<?=$day?>"></td><?
}
//-----------------------------------------------//
if ($i == $t_days && $day < 6) {
?><td colspan = "<?=(7-$day)?>"><? echo
"</td>\n</tr>\n"; }
}
if ($s==4){print "<tr>\n<td> </td></tr>";
}
?>
</table></td>
<?
}
$month = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
calendar($month);
?>