失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > PHP自动生成月历代码

PHP自动生成月历代码

时间:2022-04-15 03:02:39

相关推荐

PHP自动生成月历代码

PHP自动生成月历代码,PHP自动生成月历代码

<?php

/*

Function Written by Nelson Neoh @3/.

For those who wants to utilize this code, please do not remove this remark.

If you have done any enhancement to this code, please post the copy at . Thank you.

Function usage: calendar(Month,Year)

*/

function calendar($MM,$YYYY){

if($MM=="") $MM = date("m");

if($YYYY=="") $YYYY = date("Y");

if(checkdate($MM,1,$YYYY)){

$stringDate = strftime("%d %b %Y",mktime (0,0,0,$MM,1,$YYYY));

$days = strftime("%d",mktime (0,0,0,$MM+1,0,$YYYY));

$firstDay = strftime("%w",mktime (0,0,0,$MM,1,$YYYY));

$lastDay = strftime("%w",mktime (0,0,0,$MM,$days,$YYYY));

$printDays = $days;

$preMonth = strftime("%m",mktime (0,0,0,$MM-1,1,$YYYY));

$preYear = strftime("%Y",mktime (0,0,0,$MM-1,1,$YYYY));

$nextMonth = strftime("%m",mktime (0,0,0,$MM+1,1,$YYYY));

$nextYear = strftime("%Y",mktime (0,0,0,$MM+1,1,$YYYY));

print("<table cellpadding="0" cellspacing="0"");

print("<tr<th valign="top"<a href="".$_SERVER[PHP_SELF]."?NB=".$_GET["NB"]."&MM=".$preMonth."&YY=".$preYear.""P</a</th");

print("<th colspan="5" valign="top"".strftime("%b %Y",mktime (0,0,0,$MM,1,$YYYY))."</th");

print("<th valign="top"<a href="".$_SERVER[PHP_SELF]."?NB=".$_GET["NB"]."&MM=".$nextMonth."&YY=".$nextYear.""N</a</th</tr");

print("<tr");

print("<thSun</th<thMon</th<thTue</th<thWed</th<thThu</th<thFri</th<thSat</th</tr");

$currentDays = 1;

for($a=1;$a<=5;$a++){

print("<tr align="left" valign="top"");

$diffDays = $firstDay-$lastDay;

if($firstDay$lastDay && $currentDays ==1 && ($diffDays<1)){

for($x=$lastDay;$x=0;$x--){

$printDays = $days-$x;

print("<td$printDays</td");

}

for($z=1;$z<$firstDay-$lastDay;$z++){

print("<td&nbsp;</td");

}

&

如果觉得《PHP自动生成月历代码》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。