- /**
- * Php calendar
- * By bbs.it-home.org
- */
- If (function_exists ('date _ default_timezone_set ')){
- Date_default_timezone_set ('Asia/Chongqing ');
- }
- $ Date = isset ($ _ GET ['Date'])? $ _ GET ['Date']: date ('Y-m-D ');
- $ Date = getdate (strtotime ($ date ));
- $ End = getdate (mktime (0, 0, 0, $ date ['mon'] + 1, 1, $ date ['Year'])-1 );
- $ Start = getdate (mktime (0, 0, 0, $ date ['mon'], 1, $ date ['Year']);
- $ Pre = date ('Y-m-D', $ start [0]-1 );
- $ Next = date ('Y-m-D', $ end [0] + 86400 );
- $ Html ='
- $ Html. ='
- $ Html. ='
- $ Html. ='
- $ Html. ='
- $ Html. ='
- $ Arr_tpl = array (0 => '', 1 =>'', 2 => '', 3 =>'', 4 => '', 5 => '', 6 => '');
- Foreach ($ value as $ v ){
- } Else {
- }
- }
- }
- $ Date_arr = array ();
- $ J = 0;
- For ($ I = 0; $ I <$ end ['mday']; $ I ++ ){
- If (! Isset ($ date_arr [$ j]) {
- $ Date_arr [$ j] = $ arr_tpl;
- }
- $ Date_arr [$ j] [($ I + $ start ['wday']) % 7] = $ I + 1;
- If ($ date_arr [$ j] [6]) {
- $ J ++;
- }
- }
- Foreach ($ date_arr as $ value ){
- $ Html. ='
- If ($ v ){
- If ($ v = $ date ['mday']) {
- $ Html. ='
- $ Html. ='
- } Else {
- $ Html. ='
- }
- $ Html. ='
- $ Html. ='
';
';
- | ';
'. $ Date ['Year'].'; '. $ date ['month'].' | ';
+ | ';
';
';
'. $ V .' | ';
'. $ V .' | ';
| ';
';
';
- Echo $ html;
- ?>
2. php calendar code 2
- /**
- * Calendar
- */
- If (function_exists ('date _ default_timezone_set ')){
- Date_default_timezone_set ('Asia/Chongqing ');
- }
- $ Date = isset ($ _ GET ['Date'])? $ _ GET ['Date']: date ('Y-m-D ');
- $ Date = getdate (strtotime ($ date ));
- $ End = getdate (mktime (0, 0, 0, $ date ['mon'] + 1, 1, $ date ['Year'])-1 );
- $ Start = getdate (mktime (0, 0, 0, $ date ['mon'], 1, $ date ['Year']);
- $ Pre = date ('Y-m-D', $ start [0]-1 );
- $ Next = date ('Y-m-D', $ end [0] + 86400 );
- $ Html ='
- $ Html. ='
- $ Html. ='
- $ Html. ='
- $ Html. ='
- $ Html. ='
- $ Arr_tpl = array (0 => '', 1 =>'', 2 => '', 3 =>'', 4 => '', 5 => '', 6 => '');
- Foreach ($ value as $ v ){
- } Else {
- }
- }
- }
- $ Date_arr = array ();
- $ J = 0;
- For ($ I = 0; $ I <$ end ['mday']; $ I ++ ){
- If (! Isset ($ date_arr [$ j]) {
- $ Date_arr [$ j] = $ arr_tpl;
- }
- $ Date_arr [$ j] [($ I + $ start ['wday']) % 7] = $ I + 1;
- If ($ date_arr [$ j] [6]) {
- $ J ++;
- }
- }
- Foreach ($ date_arr as $ value ){
- $ Html. ='
- If ($ v ){
- If ($ v = $ date ['mday']) {
- $ Html. ='
- $ Html. ='
- } Else {
- $ Html. ='
- }
- $ Html. ='
- $ Html. ='
Align = "center" style = "line-height: 150%; font-family: Verdana,; font-size: 12px;"> ';
';
- | ';
'. $ Date ['Year'].'; '. $ date ['month'].' | ';
+ | ';
';
';
'. $ V .' | ';
'. $ V .' | ';
| ';
';
';
- Echo $ html;
- ?>
3. php calendar code 3:
/**
- * Php calendar code
- * Edit: bbs.it-home.org
- */
- Function calendar ()
- {
- If ($ _ GET ['ym'])
- {
- $ Year = substr ($ _ GET ['ym );
- $ Month = substr ($ _ GET ['ym'], 4, (strlen ($ _ GET ['ym'])-4 ));
If ($ month> 12)
- {
- $ Year + = floor ($ month/12 );
- $ Month = $ month % 12;
- }
- If ($ year> 2030) $ year = 2030;
- If ($ year <1980) $ year = 1980;
- }
$ Year = isset ($ year )? $ Year: date ('Y ');
- $ Month = isset ($ month )? $ Month: date ('N ');
If ($ year = date ('Y') & $ month = date ('N') $ today = date ('J ');
If ($ month-1 = 0)
- $ Prevmonth = ($ year-1). "12 ";
- Else $ prevmonth = $ year. ($ month-1 );
If ($ month + 1 = 13)
- $ Nextmonth = ($ year + 1). "1 ";
- Else $ nextmonth = $ year. ($ month + 1 );
$ Prevyear = ($ year-1). $ month;
- $ Nextyear = ($ year + 1). $ month;
Echo <
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- VKN;
- $ Count ++;
- If ($ count % 7 = 0) echo"
- $ Count ++;
- }
-
-
- $ Nowtime = mktime (0, 0, 0, $ month, 1, $ year); // convert the value 1 to the second of the current month
- $ Daysofmonth = date (t, $ nowtime); // Number of days in the current month
- $ Weekofbeginday = date (w, $ nowtime); // The Day of the week on the first day of the month
- $ Weekofendday = date (w, mktime (, 0, 0, $ month +, $ year); // The last day of the month is the day of the week.
- $ Daysofprevmonth = date (t, mktime (, 0, $ month, 0, $ year); // Number of days in the previous month
$ Count = 1; // count
- // List the days after the previous month
- For ($ I = 1; $ I <= $ weekofbeginday; $ I ++)
- {
- Echo"
- }
- // All for the current month
- For ($ I = 1; $ I <= $ daysofmonth; $ I ++)
- {
- $ Css = ($ count % 7 = 0 | $ count % 7 = 1 )? "Weekday": "normalday ";
- If ($ I = $ today) $ css. = "today ";
Echo"
- }
- // A few days before next month
- For ($ I = 1; $ I <= 6-$ weekofendday; $ I ++)
- {
- Echo"
Echo <
< |
< |
$ Year-$ month |
> |
> |
Day |
I |
II |
3. |
Thu |
V. |
Sat. |
". ($ Daysofprevmonth-$ weekofbeginday + $ I )." | ";
". $ I ." | ";
";
". $ I ." | ";
|
- VKN;
- }
- ?>
-
-
-
-
- Calendar
-
-
-
-
>>> 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 sharing example PHP simple calendar code php simple calendar implementation code (events can be bound) |