- Header ("Content-type:text/html;charset=utf-8");
- ?>
-
- /**
- * Simple and practical PHP calendar code
- * edit:bbs.it-home.org
- */
- if (!emptyempty ($_get)) {
- $year = $_get[' year '];
- $month = $_get[' month ');
- }
- if (Emptyempty ($year)) {
- $year = Date (' Y ');
- }
- if (Emptyempty ($month)) {
- $month = Date (' m ');
- }
- $start _weekday = Date (' W ', Mktime (0,0,0, $month, 1, $year));
- echo $start _weekday;
- $days = date (' t ', Mktime (0,0,0, $month, 1, $year));
- Echo $days;
- $week = Array (' Sunday ', ' Monday ', ' Tuesday ', ' Wednesday ', ' Thursday ', ' Friday ', ' Saturday ');
- $i = 0;
- $k = 1;
- $j = 0;
- Echo '
- Echo '
- Echo '
- for ($i = 0; $i < 7; $i + +) {
- }
- Echo '
- for ($j = 0; $j < $start _weekday; $j + +) {
- }
- }else{
- }
- }
- $j + +;
- echo "
- echo "
- Echo '
- echo "
- echo "
- Echo '
- Echo '
- Echo '
- Echo '
- Echo '
- while ($k <= $days) {
- if ($k = = Date (' d ')) {
- Echo '
- Echo '
- if (($j + 1)% 7 = = 0) {
- Echo '
- $j + +;
- $k + +;
- }
- while ($j% 7 = 0) {
- Echo '
- }
- Echo '
- Echo '
';
'. $year. ' Year ' $month. ' Month '. ' |
';
';
'. $week [$i]. ' | ';
';
';
'. $j. ' | ';
'. $k. ' | ';
'. $k. ' | ';
';
'. $j. ' | ';
';
';
".' << '. ' | ';
".' < '. ' | ';
';- Echo ';
- Echo '
| ';
".' >> '. ' | ';
".' > '. ' | ';
';
';
- function LastYear ($year, $month) {
- $year = $year-1;
- Return "year= $year &month= $month";
- }
- function Lastmonth ($year, $month) {
- if ($month = = 1) {
- $year = $year-1;
- $month = 12;
- }else{
- $month--;
- }
- Return "year= $year &month= $month";
- }
- function Nextyear ($year, $month) {
- $year = $year +1;
- Return "year= $year &month= $month";
- }
- function Nextmonth ($year, $month) {
- if ($month = = 12) {
- $year = $year +1;
- $month = 1;
- }else {
- $month + +;
- }
- Return "year= $year &month= $month";
- }
- ?>
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 PHP Implementation of efficient calendar code PHP calendar code Three good PHP calendar code to share a sample PHP simple calendar code PHP simple Calendar Implementation code (bindable events) |