Php simple calendar implementation code (events can be bound)
- /**
- * Php simple calendar
- * Edit: bbs.it-home.org
- */
- If (empty ($ year) $ year = date ("Y"); // initialize the year
- If (empty ($ month) $ month = date ("n"); // initialize the month
- $ Wd_ar = array ("day", "one", "two", "three", "four", "five", "six"); // array of weeks
- $ Wd = date ("w", mktime (0, 0, 0, $ month, 1, $ year); // The first day of the month is the day of the week.
- // Year link
- $ Y_lnk1 = $ year <= 1970? $ Year = 1970: $ year-1;
- $ Y_lnk2 = $ year> = 2037? $ Year = 2037: $ year + 1;
- // Monthly link
- $ M_lnk1 = $ month <= 1? $ Month = 1: $ month-1;
- $ M_lnk2 = $ month> = 12? $ Month = 12: $ month + 1;
- Echo <EOT
- EOT;
- }
- $ Tnum = $ wd + date ("t", mktime (0, 0, 0, $ month, 1, $ year ));
- Print'
- If ($ I % 7 = 6) print"
- }
- If ($ I % 7 = 6) print"
- Print'
- For ($ I = 0; $ I <7; $ I ++ ){
- Print"
- Print"
- For ($ I = 0; $ I <$ tnum; $ I ++ ){
- $ Date = $ I + 1;
- If ($ I % 7 = 0) print'
- If ($ I % 7 <6 & $ I % 7> 0) print'
| <$ Year> |
<$ Month> |
| $ Wd_ar [$ I] | ";
";
';
';
- If ($ I >=$ wd) print $ date-$ wd;
- Print"
| ";
";
|
';
|
";
';
- ?>
The above is the php calendar code introduced in this section. It provides some basic calendar functions: year, month, date, and Week display.
>>> Articles you may be interested in: php calender calendar code (solving 2038 issues) php calendar code (with demo effect) php calendar code sharing simple and practical php calendar code php efficient calendar code php calendar code three good php calendar code sharing a PHP simple calendar code |