<?php
//今日の日付を取得
$today = getdate();
$yyyy = $today[year];//年
$mm = $today[mon];//月
$dd = $today[mday];//日
// カレンダーを表示する
echo "<center>";
echo "<p><img src='./line_heart.gif' width='159' height='14'>";
echo "<table border=\"0\">";
echo "<tr align='center'><td colspan='7'>$yyyy 年 $mm
月</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr>";
echo "<td width='20'>日</td>";
echo "<td width='20'>月</td>";
echo "<td width='20'>火</td>";
echo "<td width='20'>水</td>";
echo "<td width='20'>木</td>";
echo "<td width='20'>金</td>";
echo "<td width='20'>土</td>";
echo "</tr>";
// 1日の曜日を取得する
$wd1 = date("w", mktime(0, 0, 0, $mm, 1, $yyyy));
$d = 0;
$lastd = date("d", mktime(0, 0, 0, $mm + 1, 0, $yyyy));
for ($i = 0; $i <= 5; $i++) {
if ($d > $lastd) {break;}
echo "<tr>";
for ($j = 0; $j <= 6; $j++) {
$d = $i * 7 + $j - $wd1 + 1;
if ($d > $lastd or $d < 1) {
echo "<td> </td>";
}
//今日の日付の場合はセルに色をつける
else {
if ($d == $dd ) {
echo "<td align='center' bgcolor='#CCCCCC'>$d</td>";
}
else {
echo "<td align='center'>$d</td>";
}
}
}
echo "</tr>";
}
echo "</table>";
echo "<p><img src='./line_heart.gif' width='159' height='14'>";
echo "</center>";
?> |