<?php
function date_month(){
$x=explode("-",$s);
$nowY=date('Y');
$nowM=date('m');
$nowD=date('d');
$start=date("t",mktime(0,0,0,$nowM,$nowD,$nowY));
$end=date("N",mktime(0,0,0,$nowM,1,$nowY));
$nowW=$end%7;
$w=($start+$nowW)/7;
$w=ceil($w);
$w=$w-1;
echo ("
<table>
<tr>
<th colspan=7>".$nowY."년 ".$nowM."월</th>
</tr>
<tr>
<th>일</th>
<th>월</th>
<th>화</th>
<th>수</th>
<th>목</th>
<th>금</th>
<th>토</th>
</tr>
");
for($r=0;$r<=$w;$r++){
echo "<tr>";
for($z=1;$z<=7;$z++){
$startW=7*$r+$z;
$startD=$startW-$nowW;
if($startD<=0 || $startD>$start){
echo "<td> </td>";
}else{
$s=date("Y-m-d",mktime(0,0,0,$nowM,$startD,$nowY));
if( $s == date("Y-m-d") ){
echo "<td>".$startD."</td>";
}else{
echo "<td class='now' >".$startD."</td>";
}
}
}
echo "</tr>";
}
echo "</table>";
}
?>
<div><?php date_month(); ?></div>