?? ??? ??
1, mktime() ??? ???? ?? ?? ??? ?? ? 1?? ?(2018/3/13)
<?php $day=date("t",mktime(0,0,0,$mon,1,$year));//當(dāng)前月的天數(shù) 31 $w=date("w",mktime(0,0,0,$mon,1,$year));//當(dāng)月1號的星期幾 4
2, ??? ?????. ?? ??
<?php echo"<div align='center'>"; echo"<table border='0'>"; echo"<h3><div>{$year}年{$mon}月</div></h3>"; echo "<tr>"; echo "<th>日</th>"; echo "<th class='td1'>一</th>"; echo "<th class='td1'>二</th>"; echo "<th class='td1'>三</th>"; echo "<th class='td1'>四</th>"; echo "<th class='td1'>五</th>"; echo "<th>六</th>"; echo "</tr>";
3, ?? ??? ?????
??:
mktime() ??? ?? ?? ? ? ?? ??? ? ? ????. ?? 1?? ?? ?? ? ???? ?? ???? ???? ???. 7? ?? ??? ?? ???? ?????. ?? 1?? ?? 1? ???, 7? ?? ? ?? ???? ? ?? ???? ??? ??? ????
Code:
<?php $d=1; while($d<=$day){ echo"<tr onmouseOver='overTr(this)'onmouseOut='outTr(this)'>"; for($i=1;$i<=7;$i++){//循環(huán)輸出7天信息 if($d<=$day&&($w<$i||$d!=1)){ echo "<th><a href=''>{$d}</a></th>"; $d++; }else{ echo"<th> </th>"; } } }
?? ??? ??? ????.