PHP日历
通过date函数能够自己写一个日历
1 <?php 2 header("Content-type:text/html;charset=utf-8"); 3 echo(date_sunset(time(),SUNFUNCS_RET_STRING,38.4,-9,90,1)); 4 $arr=array('星期一','星期二','星期三','星期四','星期五','星期六','星期日'); 5 $y=$_GET['y']?$_GET['y']:date("Y"); 6 $m=$_GET['m']?$_GET['m']:date("m"); 7 echo "当前是".$y."年".$m."月"; 8 echo "<table border='1' width='60%' align='center'>"; 9 echo "<tr>"; 10 foreach($arr as $val) 11 { 12 echo "<th>".$val."</th>"; 13 } 14 echo "</tr>"; 15 $w=date("N",strtotime($y."-".$m."-01")); 16 echo "<tr>"; 17 for($i=1;$i<$w;$i++) 18 { 19 echo "<td> </td>"; 20 21 } 22 $day=date("t"); 23 for($i=1;$i<=$day;$i++) 24 { 25 $n=date("N",strtotime($y."-".$m."-".$i)); 26 27 if($n%7==1) 28 { 29 echo "<tr>" ; 30 } 31 echo "<td>"; 32 echo $i; 33 echo "</td>"; 34 if($n%7==0) 35 { 36 echo "</tr>"; 37 } 38 } 39 $n=date("N",strtotime($y."-".$m."-".$day)); 40 while($n<7) 41 { 42 echo $n; 43 44 echo "<td>"; 45 echo " "; 46 echo "</td>"; 47 $n++; 48 49 } 50 echo "</table>"; 51 $ny=$y+1; 52 $nm=$m+1; 53 $by=$y-1; 54 $bm=$m-1; 55 ?> 56 <a href=study.php?y=<?php echo $by;?>&m=<?php echo $bm;?>>上一年</a> <a href=study.php?m=<?php echo $bm;?>>上一月</a> <a href=study.php?m=<?php echo $nm;?>>下一月</a> <a href=study.php?y=<?php echo $ny;?>>下一年</a>