インフォメーションカレンダー by PHP
カレンダー by PHP
<?php
// 現在の年
$year = date(Y);
// 現在の月
$month = date(m);
// 現在の年・月の1日
$day = mktime(0, 0, 0, $month, 1, $year);
// その月の最初の曜日
$first = date(w, $day);
// その月の日数
$total = date(t, $day);
// その月の週数
$week = ceil($total / 7);
if (($total % 7 > 7 - $first) || ($total % 7 == 0 && $first != 0)) {
$week++;
}
?>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th><font color="#FF0000">日</fonr></th><th>月</th><th>火</th><th>水</th><th>木</th><th>金</th><th><font
color="#000FFF">土</fonr></th>
</tr>
<tr>
<?php
echo $year . "年" . $month . "月";
for ($i=1;$i<=$week*7;$i++) {
if ($i % 7 == 1) {
echo "<tr>";
}
if (($i -1 < $first) || ($i > $total + $first)) {
echo "<td align=center><font color=#c0c0c0>・</font></td>";
} else {
if ($i % 7 == 1) {
$col = "#FF0000";
} elseif ($i % 7 == 0) {
$col = "#000FFF";
} else {
$col = "#000000";
}
echo "<td align=center><font color=" . $col . ">" . ($i - $first) . "</font></td>";
}
if ($i % 7 == 0) {
echo "</tr>";
}
}
?>
</tr>
</table>
posted on Tuesday, July 13th, 2010 at 1:51 am
You can leave a response, or trackback from your own site.