本文实例讲述了php实现的日历程序。分享给大家供大家参考。具体如下:
<"Y"): $_GET["Year"]; $Month = empty($_GET['Month']) "m"): $_GET["Month"]; ////获取当前日期//// $Today = date("Ymj"); ////初始化日期数组//// $Maxday = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20", "21","22","23","24","25","26","27","28","29","30","31"); $Maxday_count = count($Maxday); ////初始化星期数组//// $Weekday = array("<font color='red'>Sun</font>","Mon","Tue","Wed","Thu","Fri","<font color='red'>Sat</font>"); $Weekday_count = count($Weekday); $daynum = 0; $space = "<td> </td>"; $col = 0; ////打印表格头部//// "calendar.php" method="post" name="linked"> <table><tr><td colspan=3 align=center><a href="" onClick="javascript:document.linked.submit();" name="Year"><<</a> <"" onClick="javascript:document.linked.submit();" name="Year"></a></td> <td> </td><td colspan=3 align=center><a href=""0".($Month-1); else echo $Month-1; else echo $Month;" onClick="javascript:document.linked.submit();" name="Month"><<</a> <""0".($Month+1);else echo ($Month+1); else echo $Month;" onClick="javascript:document.linked.submit();" name="Month"></a></td></tr><tr><td colspan="8"></td></tr><tr> <"<td align=center> ".$Weekvalue." </td>"; echo "</tr>"; ////打印日期列表//// //当月份为4,6,9,11的时候,从数组末尾删除一个值,也就是删除31这个值. if($Month == 4 or $Month == 6 or $Month == 9 or $Month == 11) { array_pop($Maxday); $Maxday_count--; } //先判断月份是否为2月,如果是的话再判断年份是否为闰年,如果是的话就从数组尾部移除2个值,否则就移除3个值. if($Month == 2) { if($Year % 4 == 0) { array_pop($Maxday); array_pop($Maxday); $Maxday_count-=2; } else { array_pop($Maxday); array_pop($Maxday); array_pop($Maxday); $Maxday_count-=3; } } ////打印日期//// while($daynum < $Maxday_count) { echo "<tr>"; while(list($colnum,$Dayvalue) = each($Maxday)) { //判断当前日期为一星期中的哪一天 $DayWeek = date("w",strtotime($Year."-".$Month."-".$Dayvalue)); //当当前日期处于第1个,也就是每个月的第1天的时候,在它前面补上相应的空格子 if($Dayvalue == 1) for($i=0;$i<$DayWeek;$i++) echo $space;//打印每个月空出的几个格子 $daynum++; //当打印日期的时候与当前日期字符串进行比较,如果相等就将字体标为红色. if($Year.$Month.$Dayvalue == $Today) { $u1 = "<b><u>"; $u2 = "</b></u>"; } else { $u1 = ""; $u2 = ""; } if($DayWeek == 0 or $DayWeek == 6) $color = "red"; else $color = "black"; echo "<td align=center><font color=".$color."> ".$u1.$Dayvalue.$u2." </font></td>"; //用本周第几天这个值加1,如果是7的倍数就换行退出此轮循环(换行打印) if(($DayWeek+1) % 7 == 0) { $col++; break; } } echo "</tr>"; } "//img.jbzj.com/file_images/article/201506/2015618163924357.jpg" alt="" />希望本文所述对大家的php程序设计有所帮助。
标签:
php,日历程序
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“php实现的日历程序”评论...
P70系列延期,华为新旗舰将在下月发布
3月20日消息,近期博主@数码闲聊站 透露,原定三月份发布的华为新旗舰P70系列延期发布,预计4月份上市。
而博主@定焦数码 爆料,华为的P70系列在定位上已经超过了Mate60,成为了重要的旗舰系列之一。它肩负着重返影像领域顶尖的使命。那么这次P70会带来哪些令人惊艳的创新呢?
根据目前爆料的消息来看,华为P70系列将推出三个版本,其中P70和P70 Pro采用了三角形的摄像头模组设计,而P70 Art则采用了与上一代P60 Art相似的不规则形状设计。这样的外观是否好看见仁见智,但辨识度绝对拉满。