
달력 PHP 소스
<style type='text/css'>
#calendar {
border-collapse:collapse;
font-size:9pt;
}
#calendar th { border:1px solid #E6E6E6; background:#D2D2D2; }
#calendar td { border:1px solid #E6E6E6; }
#calendar .bgSat { background:#EEF7FF; }
#calendar .bgSun { background:#FFECEC; }
#calendar a:link { text-decoration:none; }
#calendar a:hover { text-decoration:none; }
#calendar a:visited { text-decoration:none; }
#calendar a:active { text-decoration:none; }
</style>
<?
$date = $_GET['date'];
if( eregi("^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$",$date) ){
$t = explode("-",$date);
$year =$t[0];
$month =$t[1];
$day =$t[2];
}else{
$year = date("Y");
$month = date("m");
$day = date("d");
}
$timestemp = mktime(0,0,0,$month,1,$year);
$start_week = date("w",$timestemp);
$last_day = date("t",$timestemp);
$prev_date = date("Y-m-d",mktime(0,0,0,$month-1,1,$year));
$next_date = date("Y-m-d",mktime(0,0,0,$month+1,1,$year));
echo "<table border='0' cellpadding='5' cellspacing='0' id='calendar'>";
echo "<caption><a href='?date=$prev_date'><</a> $year/$month <a href='?date=$next_date'>></a></caption>";
echo "<tr><th>Sun</th><th>Mon</th><th>Tue</th><th>Wed</th><th>Thu</th><th>Fri</th><th>Sat</th></tr>";
echo "<tr>";
for( $i = 0 ; $i < $start_week ; $i++ )
{
echo "<td></td>";
}
for( $days = 1 ; $days <= $last_day ; $days++)
{
$i++;
$_days = sprintf("%02d",$days);
$className = "";
if( $i%7 == 1 ) $className="class='bgSun'";
if( $i%7 == 0 ) $className="class='bgSat'";
echo "<td $className>$_days</td>";
if( $i%7 == 0 ) echo "</tr><tr>\n";
}
while(1)
{
if( $i%7 == 0 ) break;
$i++;
echo "<td></td>";
if( $i%7 == 0 ){ echo "</tr>"; break;}
}
echo "</table>";
?>
TRACKBACK :: http://blueb.net/blog/trackback/742