PhpCalender (calendar) code & lt ;? Php ***** my calendar * date_default_timezone_setdatemktime * @ paramint $ year * @ paramint $ month * @ paramstring $ timezone * @ authorfc_lamp * @ blog: http: php Calender (calendar) code
= 2038) {$ year = date ('Y') ;}} else {if ($ year <= 0) {$ year = date ('Y ');}} if ($ month <= 0 or $ month> 12) {$ month = date ('M');} // Previous year $ pretYear = $ year-1; // last month $ mpYear = $ year; $ preMonth = $ month-1; if ($ preMonth <= 0) {$ preMonth = 1; $ mpYear = $ pretYear ;} // next year $ nextYear = $ year + 1; // next month $ mnYear = $ year; $ nextMonth = $ month + 1; if ($ nextMonth> 12) {$ nextMonth = 1; $ mnYear = $ nextYear;} // calendar header $ html = <
Last year Last month Back to today Next month Next year {$ Year}-{$ month} month
| Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
Sunday |
HTML; $ currentDay = date ('Y-m-J'); // The last day of the month $ lastday = date ('J', mktime (0, 0, 0, $ nextMonth, 0, $ year); // cyclic output days $ day = 1; $ line = ''; while ($ day <= $ lastday) {$ cday = $ year. '-'. $ month. '-'. $ day; // The current day of the week $ nowWeek = date ('N', mktime (0, 0, 0, $ month, $ day, $ year )); if ($ day = 1) {$ line ='
'; $ Line. = str_repeat ('
| | ', $ NowWeek-1);} if ($ cday ==$ currentDay) {$ style = 'style = "color: red ;"';} else {$ style = '';} $ line. ="
$ Day | "; // End of a week if ($ nowWeek = 7) {$ line. ='
'; $ Html. = $ line; $ line ='
';} // If ($ day ==$ lastday) {if ($ nowWeek! = 7) {$ line. = str_repeat ('
| | ', 7-$ nowWeek);} $ line. ='
'; $ Html. = $ line; break;} $ day ++;} $ html. = <
HTML; return $ html;}/*** check whether it is a 32-bit host * @ author fc_lamp * @ blog: fc-lamp.blog.163.com */function is32 () {$ is32 = False; if (strtotime ('1970-10-10 ') === False) {$ is32 = True;} return $ is32 ;}