电话:13815259105
QQ:19500067
邮箱:huangjing@gggsoft.com
联系:黄 晶
php日历代码    编辑:admin      时间:2013-10-25
<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;?>">&lt;&lt;</a> &nbsp;&nbsp;
<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> 月 &nbsp;&nbsp;
<a href="<?php echo $next_url;?>">&gt;&gt;</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;
}
?>

 


转载请注明本站出处:闪际软件-认证流程管理软件
http://www.gggsoft.com/action-desgin_log-id-13.html
© CopyRight 2013-2020   苏州闪际软件有限公司    苏ICP备13025141号   
友情链接:认证流程管理软件 认证机构软件 认证管理软件 快递查询