Programming/PHP / / 2023. 11. 8. 11:00

달력

728x90
<?php
$year = date('Y');
$month = date('n');
list($week, $last_day) = preg_split('[-]', date('w-t', mktime(0, 0, 1, $month, 1, $year)));
?>
현재 : <?=$year?>년 <?=$month?>월
<table>
<tr>
<th>일</th>
<th>월</th>
<th>화</th>
<th>수</th>
<th>목</th>
<th>금</th>
<th>토</th>
</tr>
<tr>
<?php
$j = 1;
for($i = (1 - $week); $i <= $last_day; $i++) {
echo '<td>'.($i > 0 ? $i : '').'</td>';
if($j % 7 == 0) echo '</tr><tr>';
$j++;
}
?>
</tr>
</table>
view raw calendar.php hosted with ❤ by GitHub

[샘플]

이전, 다음 없고 아무런 스타일도 없습니다. 나머지는 직접 구현하면 됩니다.

반응형