- /**
- * PHP Calendar
- * by bbs.it-home.org
- */
- if (function_exists (' Date_default_timezone_set ')) {
- Date_default_timezone_set (' asia/chongqing ');
- }
- $date = isset ($_get[' date ')? $_get[' Date ': Date (' y-m-d ');
- $date = getdate (Strtotime ($date));
- $end = getdate (mktime (0, 0, 0, $date [' mon '] + 1, 1, $date [' Year '])-1);
- $start = getdate (mktime (0, 0, 0, $date [' mon '], 1, $date [' Year ']);
- $pre = Date (' y-m-d ', $start [0]-1);
- $next = Date (' y-m-d ', $end [0] + 86400);
- $html = '
- $html. = '
- $html. = '
- $html. = '
- $html. = '
- $html. = '
- $arr _tpl = Array (0 = ', 1 = ', 2 = ', 3 = ', 4 = ', 5 = ', 6 = ');
- foreach ($value as $v) {
- } else {
- }
- }
- }
- $date _arr = Array ();
- $j = 0;
- for ($i = 0; $i < $end [' Mday ']; $i + +) {
- if (!isset ($date _arr[$j])) {
- $date _arr[$j] = $arr _tpl;
- }
- $date _arr[$j] [($i + $start [' wday '])%7] = $i +1;
- if ($date _arr[$j][6]) {
- $j + +;
- }
- }
- foreach ($date _arr as $value) {
- $html. = '
- if ($v) {
- if ($v = = $date [' mday ']) {
- $html. = '
- $html. = '
- } else {
- $html. = '
- }
- $html. = '
- $html. = '
';
';
| - | ';
' . $date [' Year ']. ';' . $date [' Month ']. ' | ';
+ | ';
';
';
| ' . $v. ' | ';
' . $v. ' | ';
| ';
';
';
- Echo $html;
- ?>
Copy Code2,php Calendar Code 2
- /**
- * Calendar
- */
- if (function_exists (' Date_default_timezone_set ')) {
- Date_default_timezone_set (' asia/chongqing ');
- }
- $date = isset ($_get[' date ')? $_get[' Date ': Date (' y-m-d ');
- $date = getdate (Strtotime ($date));
- $end = getdate (mktime (0, 0, 0, $date [' mon '] + 1, 1, $date [' Year '])-1);
- $start = getdate (mktime (0, 0, 0, $date [' mon '], 1, $date [' Year ']);
- $pre = Date (' y-m-d ', $start [0]-1);
- $next = Date (' y-m-d ', $end [0] + 86400);
- $html = '
- $html. = '
- $html. = '
- $html. = '
- $html. = '
- $html. = '
- $arr _tpl = Array (0 = ', 1 = ', 2 = ', 3 = ', 4 = ', 5 = ', 6 = ');
- foreach ($value as $v) {
- } else {
- }
- }
- }
- $date _arr = Array ();
- $j = 0;
- for ($i = 0; $i < $end [' Mday ']; $i + +) {
- if (!isset ($date _arr[$j])) {
- $date _arr[$j] = $arr _tpl;
- }
- $date _arr[$j] [($i + $start [' wday '])%7] = $i +1;
- if ($date _arr[$j][6]) {
- $j + +;
- }
- }
- foreach ($date _arr as $value) {
- $html. = '
- if ($v) {
- if ($v = = $date [' mday ']) {
- $html. = '
- $html. = '
- } else {
- $html. = '
- }
- $html. = '
- $html. = '
align= "center" style= "line-height:150%; Font-family:verdana, song body; font-size:12px; " > ';
';
| - | ';
' . $date [' Year ']. ';' . $date [' Month ']. ' | ';
+ | ';
';
';
| ' . $v. ' | ';
' . $v. ' | ';
| ';
';
';
- Echo $html;
- ?>
Copy Code3,php Calendar Code Three:
/**
- * PHP Calendar Code
- * edit:bbs.it-home.org
- */
- function Calendar ()
- {
- if ($_get[' ym ')
- {
- $year = substr ($_get[' ym '],0,4);
- $month = substr ($_get[' ym '],4, (strlen ($_get[' ym ")-4));
if ($month >12)
- {
- $year + = Floor ($month/12);
- $month = $month% 12;
- }
- if ($year > 2030) $year = 2030;
- if ($year < 1980) $year = 1980;
- }
$year = Isset ($year)? $year: Date (' Y ');
- $month = Isset ($month)? $month: Date (' n ');
if ($year ==date (' Y ') && $month ==date (' n ') $today = date (' j ');
if ($month-1 = = 0)
- $prevmonth = ($year-1). " 12 ";
- else $prevmonth = $year. ($month-1);
if ($month +1 = = 13)
- $nextmonth = ($year + 1). " 1 ";
- else $nextmonth = $year. ($month + 1);
$prevyear = ($year-1). $month;
- $nextyear = ($year + 1). $month;
Echo <<
-
- VKN;
- $count + +;
- if ($count%7==0) echo "
- $count + +;
- }
- }
- All of the Month
- for ($i = 1; $i <= $daysofmonth; $i + +)
- {
- $css = ($count%7==0 | | $count%7==1)? " Weekday ":" Normalday ";
- if ($i = = $today) $css. = "Today";
echo "
- }
- A few days before next month
- for ($i = 1; $i <= 6-$weekofendday; $i + +)
- {
- echo "
Echo <<
-
| << |
< |
$year-$month |
> |
>> |
| Day |
One |
Two |
Three |
Four |
Five |
Six |
- $nowtime = Mktime (0,0,0, $month, 1, $year);//1th to seconds of the month
- $daysofmonth = Date (t, $nowtime);//Days of the Month
- $weekofbeginday = Date (w, $nowtime);//The first day of the month is the days of the week
- $weekofendday = Date (W,mktime (0,0,0, $month +1,0, $year));//The Last day of the month is the days of the week
- $daysofprevmonth = Date (T,mktime (0,0,0, $month, 0, $year));//number of days last month
$count = 1;//Count
- List the days after last month
- for ($i = 1; $i <= $weekofbeginday; $i + +)
- {
- echo "
| ". ($daysofprevmonth-$weekofbeginday + $i). " | ";
". $i." | ";
";
| ". $i." | ";
|
- VKN;
- }
- ?>
-
- Calendar
-
Copy Code>>> you may be interested in the article: PHP Calender Calendar code (solve 2038 problems) PHP Calendar code (with demo effect) PHP Calendar code sharing simple and useful PHP calendar code PHP calendar code PHP implementation of the efficient calendar code to share a sample PHP simple calendar code PHP simple Calendar Implementation code (bindable events) |