|
Calendar
$ MONTH = array ("lunar January", "January", "February", "March", "April", "May", "June", "July ", "May August", "May September", "May October", "May November", "May December ");
$ EnMONTH = array ("lunar January", "January", "February", "Marcy", "Jun L", "May", "June", "July ", "August", "September", "October", "November", "December ");
$ WEEK = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
$ BACKCOLOR = array ("# FFC", "# FFF", "#9F6", "# FFC", "#6F0", "#6F6", "# F90 ", "# F06", "# F00", "# FC3", "# FF6", "# F99 ");
Function PrintMon ($ year, $ mon)
{
Date_default_timezone_set ("Asia/Shanghai ");
Global $ MONTH;
Global $ enMONTH;
Global $ WEEK;
Global $ BACKCOLOR;
$ Startdate = strtotime ("1 $ enMONTH [$ mon] $ year"); // Obtain the year and month of the query.
$ Enddate = strtotime ("+ 1 month", $ startdate); // Obtain the start date of the next month as the end time of the calendar output.
$ TheDate = getdate ($ startdate); // Convert the date to the string format
$ Color = $ BACKCOLOR [$ mon]; // sets the background color of the calendar.
Echo ("
$ Ym = $ year. "year". $ MONTH [$ mon];
Echo ("
Echo ("
For ($ I = 0; $ I <7; $ I ++) // outputs the day of the week
{
Echo ("
}
Echo ("
$ TheWeek = $ theDate [wday]; // determines the day of the week.
For ($ I = 0; $ I <6; $ I ++)
{
Echo ("
For ($ j = 0; $ j <7; $ j ++)
{
Echo ("
}
Echo ("
If ($ startdate = $ enddate) // if all dates have been output, end the cycle
{
$ I = 6;
}
}
Echo ("
?>
$ Month = $ _ POST ['mymonth'];
If (is_numeric ($ year) & $ year> = 1970 & $ year <2038)
{
If (is_numeric ($ month) & $ month >=1 & $ month <= 12)
{
PrintMon ($ year, $ month );
}
Else if ($ month! = NULL)
{
Echo ("The month is incorrect "."
");
}
}
Else if ($ year! = NULL)
{
Echo ("The year is incorrect "."
");
}
?>
}
$ Year = $ _ POST ['myyear'];
");
$ Ym
");
");
| ");
Echo ("$ WEEK [$ I]");
Echo (" | ");
");
");
| ");
If ($ startdate <$ enddate & $ theWeek = $ j) // output the date to the column of the corresponding day of the week, and be sure not to exceed the date of this month
{
$ TheDay = $ theDate [mday];
Echo ("$ theDay ");
$ Startdate = strtotime ("+ 1 day", $ startdate); // one day before the date
$ TheDate = getdate ($ startdate); // update the date
$ TheWeek = ($ theWeek + 1) % 7; // update week
}
Echo (" | ");
");
Workshop this article mainly introduces PHP output calendar table code examples. This article provides code examples directly. if you need a friend, can you refer? 1 2 3 4 5 6 7 8 9 10 11 12...
|