There are many calendars written in JavaScript on the Internet. These calendars read local time and may be inaccurate. So I want to find a calendar written in php that can read the server time, But I still cannot find a suitable one, so I tried to write it myself. Code copy box
<? Php $ mnow = (isset ($ HTTP_GET_VARS ['month']) & intval ($ HTTP_GET_VARS ['month'])> 0 & intval ($ HTTP_GET_VARS ['month']) <13 )? Intval ($ HTTP_GET_VARS ['month']): date ("m"); $ ynow = (isset ($ HTTP_GET_VARS ['Year']) & intval ($ HTTP_GET_VARS ['Year'])> 1969 & intval ($ HTTP_GET_VARS ['Year']) <2038 )? Intval ($ HTTP_GET_VARS ['Year']): date ("Y"); $ mtime = mktime (0, 0, 0, $ mnow, date ("d "), $ ynow); $ f = date ("w", mktime (0, 0, 0, $ mnow, 1, $ ynow)-1; echo "<table id = \" calendar \ "border = \" 0 \ "cellpadding = \" 2 \ "cellspacing = \" 1 \ "> "; echo "<tr> <td colspan = \" 4 \ "align = \" center \ "class = \" calendartitle \ "> <a href = \"? ". ($ Mnow! = Date ("m ")? "Month =". intval ($ mnow). "&": ""). "year =". (intval ($ ynow) = 1970? "1970": intval ($ ynow)-1). "\"> </a> ". $ ynow." <a href = \"? ". ($ Mnow! = Date ("m ")? "Month =". intval ($ mnow). "&": ""). "year =". (intval ($ ynow) = 2037? "2037": intval ($ ynow) + 1 ). "\" >></a> </td> <td colspan = \ "3 \" align = \ "center \" class = \ "calendartitle \"> <a href = \"? Month = ". (intval ($ mnow) = 1? "12": intval ($ mnow)-1). ($ ynow! = Date ("Y ")? "& Year = ". intval ($ ynow ):""). "\"> </a> ". date ("M", $ mtime ). "<a href = \"? Month = ". (intval ($ mnow) = 12? "1": intval ($ mnow) + 1). ($ ynow! = Date ("Y ")? "& Year = ". intval ($ ynow ):""). "\" >></a> </td> </tr> "; echo "<tr> <td class = \" calendartop \ "> S </td> <td class = \" calendartop \ "> M </td> <td class = \ "calendartop \"> T </td> <td class = \ "calendartop \"> W </td> <td class = \ "calendartop \"> T </td> <td class = \ "calendartop \"> F </td> <td class = \ "calendartop \"> S </td> </tr> "; for ($ I = 0; $ I <date ("t", $ mtime) + $ f + 1; $ I ++) {if ($ I % 7 = 0) echo "<tr>"; echo "<td ". ($ I-$ f = intval (date ("d") & $ mnow = d Ate ("m") & $ ynow = date ("Y "))? "Id = \" calendartoday \ "": ""). ($ I % 7 = 0
$ I % 7 = 6 )? "Class = \" calendarw \"":""). ">"; if ($ I> $ f) echo $ I-$ f; echo "</td>"; if ($ I % 7 = 6) echo "</tr>" ;}if ($ I % 7 <6 & $ I % 7> 0) echo "<td colspan = \"". (7-$ I % 7 ). "\"> </td> </tr> "; if ($ I % 7 = 6) echo" <td> </tr> "; echo "</table>" ;?>
[Ctrl + A select all and copy]