<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="./first/js/jquery-1.7.2.min.js" ></script> <?php $year = $_GET['year']; $month = $_GET['month']; $year == '' && $year = date("Y"); $month == '' && $month = date("m"); $all_day = date("t",strtotime($year.'-'.$month.'-01')); $d_day_s = date("N",strtotime($year.'-'.$month.'-01')); $d_day_e = date("N",strtotime($year.'-'.$month.'-'.$all_day)); $top_date = change_date(strtotime($year.'-'.$month.'-01'),-1,'m'); $top_year = date("Y",$top_date); $top_month = date("m",$top_date); $top_url = "1.php?year=$top_year&month=$top_month"; $next_date = change_date(strtotime($year.'-'.$month.'-01'),1,'m'); $next_year = date("Y",$next_date); $next_month = date("m",$next_date); $next_url = "1.php?year=$next_year&month=$next_month"; ?> <script type="text/javascript"> $(document).ready(function(){ $('#year').change(function(){ var year = $('#year').val(); var month = $('#month').val(); window.location.href="1.php?year="+year+"&month="+month; }); $('#month').change(function(){ var year = $('#year').val(); var month = $('#month').val(); window.location.href="1.php?year="+year+"&month="+month; }); }); </script> <div style="background-color:#FFFFFF;"> <table style="border-collapse:collapse;border:none;text-align:center;margin:auto" width="600px"> <tr><td colspan="7" align="center" height="28"> <a href="<?php echo $top_url;?>"><<</a> <select id="year" style="width:60px"> <?php for($i=$year-5;$i<$year+2;$i++){ $i == $year ? $year_sel = 'selected="selected"' : $year_sel = ''; echo "<option value=\"$i\" $year_sel>$i</option>"; } ?> </select> 年 <select id="month" style="width:40px"> <?php for($i=1;$i<=12;$i++){ $i == $month ? $month_sel = 'selected="selected"' : $month_sel = ''; echo "<option value=\"$i\" $month_sel>$i</option>"; } ?> </select> 月 <a href="<?php echo $next_url;?>">>></a> </td></tr> <tr> <td style="border:1px solid #CCCCCC">星期一</td> <td style="border:1px solid #CCCCCC">星期二</td> <td style="border:1px solid #CCCCCC">星期三</td> <td style="border:1px solid #CCCCCC">星期四</td> <td style="border:1px solid #CCCCCC">星期五</td> <td style="border:1px solid #CCCCCC">星期六</td> <td style="border:1px solid #CCCCCC">星期天</td> </tr> <tr> <?php for($i=2-$d_day_s;$i<=$all_day+(7-$d_day_e);$i++){ $ti++; $tdi = $i; $tdi_msg = $tdi; if($i<=0){ $str_date = strtotime($year.'-'.$month.'-01')-(1-$i)*24*3600; $tdi=date("j",$str_date); $tdi_msg = '<i style="color:gray">'.$tdi.'</i>'; }elseif($i>$all_day){ $str_date = strtotime($year.'-'.$month.'-'.$all_day)+($i-$all_day)*24*3600; $tdi=date("j",$str_date); $tdi_msg = '<i style="color:gray">'.$tdi.'</i>'; }else{ $tdi_msg = '<b>'.$tdi.'</b>'; $str_date = strtotime($year.'-'.$month.'-'.$tdi); } echo "<td style=\"border:1px solid #CCCCCC;\"><table width=100%> <tr><td align=center>$tdi_msg</td></tr> </table></td>"; $tr = ''; $ti % 7 == 0 && $tr = "</tr>\n<tr>"; echo $tr; } ?> </tr> </table> </div> <?php function change_date($time,$num,$kind='d'){ $y = date("Y",$time); $m = date("m",$time); $d = date("d",$time); $h = date("h",$time); $i = date("i",$time); $s = date("s",$time); switch($kind){ case 'y' : $new_time = mktime(0,0,0,$m,$d,$y+$num);break; case 'm' : $new_time = mktime(0,0,0,$m+$num,$d,$y);break; case 'd' : $new_time = mktime(0,0,0,$m,$d+$num,$y);break; case 'h' : $new_time = mktime($h+$num,$i,$s,$m,$d,$y);break; case 'i' : $new_time = mktime($h,$i+$num,$s,$m,$d,$y);break; case 's' : $new_time = mktime($h,$i,$s+$num,$m,$d,$y);break; default:$new_time = mktime(0,0,0,$m,$d+$num,$y); } return $new_time; } ?>