戻る      calendar.php      checkdate.php

《PHP言語 /calendar.php》

<?php
if($_GET['num']==''){
$today_year =date("Y");
$today_month=date("n");
}else{
$timestamp=mktime(0,0,0,date("n")+$_GET['num'],date("d"),date("Y"));
$today_year =date("Y",$timestamp);
$today_month=date("n",$timestamp);
}
$current=mktime(0,0,0,$today_month,1,$today_year);
$first_day=date("w",$current);
$last_day=date("t",$current);
?>
<html>
<head>
<title>万年カレンダ</title>
</head>
<body>
<h1 style="background:#cccccc">
<?php print(date("Y年m月",$current)); ?>のカレンダ</h1>
<table border="1" width="300">
<tr>
<th>日</th><th>月</th><th>火</th><th>水</th>
<th>木</th><th>金</th><th>土</th>
</tr>
<?php
for($i=1;$i<=$first_day+$last_day;$i++){
if($i%7==1){print("<tr>");}
if($i>$first_day){
print("<td>".($i-$first_day)."</td>");
}else{
print("<td>&nbsp;</td>");
}
if($i%7==0){print("</tr>");}
}
?>
</table>
</body>
</html>

 


《PHP言語 /checkdate.php》

<?php
print("2005年2月のカレンダ<br />");
for($i=1;$i<32;$i++){
if(checkdate(2,$i,2005)){print("$i &nbsp;");}
}
?>