カレンダー

pearカレンダーの方法
pearを利用するとカレンダーが楽に表示します。


スポンサーリンク

デモサイト

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<h2>PEARカレンダー</h2>
<?php
//PEARのCalendarライブラリを読み込む */
require_once("Calendar/Month/Weekdays.php");
 
//Calendarライブラリを作成する
$calMonth = new Calendar_Month_Weekdays(date("Y"), date("m"), 1);
 
//カレンダーの子オブジェクトを作成
$calMonth->build();
 
//カレンダーを表示する
 
echo "<h4>" . $calMonth->thisYear() . "年" . $calMonth->thisMonth() . "月のカレンダー</h4>";
echo '<p><table class="cal"><thead><tr>';
echo '<table class="cal"><thead><tr>';
echo '<th> 月</th><th>火</th><th>水</th><th>木</th><th>金</th><th>土</th><th>日</th>';
echo '</tr></thead><tbody>';
while ($day = $calMonth->fetch()) {
    if ($day->isFirst()) {
        echo '<tr>';
    }
    if ($day->isEmpty()) {
        echo '<td>&nbsp;</td>';
    } else {
        echo '<td>'.$day->thisDay().'</td>';
    }
    if ($day->isLast()) {
        echo '</tr>';
    }
}
echo '</tbody></table>'; 
?>
Pocket
LINEで送る

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です