? Php ** simple PHP calendar instance * Author: Many cainiao * mailbox: kingerqATmsnDOTcom * Source: blog. csdn. netkingerq * Creation Time: 2008-01-03 ** $ datepreg_match (d {4}-d {2}-d {2}, $ _ GET [YMD])? $ _ GET [YMD]: date (Y-m-d); $ thisYeardate (
? Php/** PHP simple calendar instance * Author: Many cainiao * mailbox: kingerq AT msn DOT com * Source: http://blog.csdn.net/kingerq/ * Creation Time: 2008-01-03 **/$ date = preg_match (// d {4}/-/d {2}/-/d {2}/, $ _ GET [YMD])? $ _ GET [YMD]: date (Y-m-d); $ thisYear = date (
/*
* PHP simple calendar instance
* Author: Many cainiao
* Email: kingerq AT msn DOT com
* Source: http://blog.csdn.net/kingerq/
* Creation Time:
**/
$ Date = preg_match ("// d {4}/-/d {2}/-/d {2}/", $ _ GET ["YMD"])? $ _ GET ["YMD"]: date ("Y-m-d ");
$ ThisYear = date ("Y", strtotime ($ date ));
$ ThisMonth = date ("m", strtotime ($ date ));
$ FirstDay = date ("w", strtotime ($ thisYear. "-". $ thisMonth. "-01 "));
$ MonthNum = date ("t", strtotime ($ date ));
?>
Calendar
"> <Last Year
"> <Last Month
"> Next Month>
"> Next Year>
Today |
>
>
$ I ++;
$ Num ++;
If ($ num % 7 = 0) break;
}
While ($ num % 7! = 0) {// list empty cell
?>
|
SUN |
MON |
TUE |
WED |
THU |
FRI |
SAT |
$ I = 1;$ Num = 0;While (1) {// row?>
While ($ I <= $ monthNum) {// list dayWhile ($ firstDay) {// empty in front?>
| | $ FirstDay --;$ Num ++;}$ Daykey = str_pad ($ I, 2, 0, STR_PAD_LEFT );$ ThisDay = date ("Y-m-d", strtotime ($ thisYear. "-". $ thisMonth. "-". $ daykey ));$ Week = date ("w", strtotime ($ thisDay ));$ ClassName = ($ week % 7 = 0? "Class = 'sunday'": ($ week % 7 = 6? "Class = 'saturday '":""));?>
| $ Num ++;}?>
If ($ I >=$ monthNum) break;}?>
| |
|
|
|
|
|
|