Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Php Programming Code Examples

Php > Date Time Code Examples

Customizable Calendar Class

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
Customizable Calendar Class <? class calendar { var $daynamefont,$daynamebgcolor,$daynamecolor,$daynamesize,$daynamebold,$daynameitalic , $dayfont,$daybgcolor,$daycolor,$dayactivecolor,$daysize,$daybold,$dayitalic, $showdate,$bordersize,$timestamp; function calendar(){ if(empty($this->daynamefont)==true)$this->daynamefont="Arial, sans-serif"; if(empty($this->daynamebgcolor)==true)$this->daynamebgcolor="#000060"; if(empty($this->daynamecolor)==true)$this->daynamecolor="#FFFFFF"; if(empty($this->daynamesize)==true)$this->daynamesize="3"; if(empty($this->daynamebold)==true)$this->daynamebold=true; if(empty($this->daynameitalic)==true)$this->daynameitalic=false; if(empty($this->dayfont)==true)$this->dayfont="Arial, sans-serif"; if(empty($this->daybgcolor)==true)$this->daybgcolor="#FFCA00"; if(empty($this->daycolor)==true)$this->daycolor="#000000"; if(empty($this->dayactivecolor)==true)$this->dayactivecolor="#FF0000"; if(empty($this->daysize)==true)$this->daysize="3"; if(empty($this->daybold)==true)$this->daybold=true; if(empty($this->dayitalic)==true)$this->dayitalic=false; if(empty($this->showdate)==true)$this->showdate=true; if(empty($this->bordersize)==true)$this->bordersize="2"; if(empty($this->timestamp)==true)$this->timestamp=time(); } function show(){ $day=date("j",$this->timestamp); $month=date("n",$this->timestamp); $year=date("Y",$this->timestamp); if($this->daynamebold==true){ $daynametextprefix="<b>"; $daynametextsuffix="</b>"; } if($this->daynameitalic==true){ $daynametextprefix.="<i>"; $daynametextsuffix="</i>".$daynametextsuffix; } if($this->daybold==true){ $daytextprefix="<b>"; $daytextsuffix="</b>"; } if($this->dayitalic==true){ $daytextprefix.="<i>"; $daytextsuffix="</i>".$daytextsuffix; } if(checkdate($month,$day,$year)==true){ $maxdays=31; while(checkdate($month,$maxdays,$year)==false)$maxdays--; $startday=1-date("w",mktime(0,0,0,$month,1,$year)); print("<table border='".$this->bordersize."' cellspacing='0' cellpadding='0'><tr bgcolor='".$this->daybgcolor."'><td>\n"); print(" <table border='0' cellspacing='0' cellpadding='2'>\n"); if($this->showdate==true)print(" <tr bgcolor='".$this->daynamebgcolor."'><td colspan='7'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this- >daynamesize."'><div align='center'>".$daynametextprefix.date("F",mktime (0,0,0,$month,$day,$year))." $year".$daynametextsuffix."</div></font></td></tr>\n"); print(" <tr bgcolor='".$this->daynamebgcolor."'><td align='center'><font face='".$this- >daynamefont."' color='".$this->daynamecolor."' size='".$this- >daynamesize."'>".$daynametextprefix." S ".$daynametextsuffix."</font></td><td align='center'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this->daynamesize."'>".$daynametextprefix." M ".$daynametextsuffix."</font></td><td align='center'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this->daynamesize."'>".$daynametextprefix." T ".$daynametextsuffix."</font></td><td align='center'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this->daynamesize."'>".$daynametextprefix." W ".$daynametextsuffix."</font></td><td align='center'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this->daynamesize."'>".$daynametextprefix." T ".$daynametextsuffix."</font></td><td align='center'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this->daynamesize."'>".$daynametextprefix." F ".$daynametextsuffix."</font></td><td align='center'><font face='".$this->daynamefont."' color='".$this->daynamecolor."' size='".$this->daynamesize."'>".$daynametextprefix." S ".$daynametextsuffix."</font></td>"); $weekdaycount=0; for($daycount=$startday;$daycount<=$maxdays;$daycount++){ if(($weekdaycount%7)==0)print("</tr>\n <tr bgcolor='".$this->daybgcolor."'>"); if($daycount>0){ print("<td align='right'>"); if($daycount!=$day){ print("<font face='".$this->dayfont."' color='".$this->daycolor."' size='".$this- >daysize."'>".$daytextprefix." ".$daycount." ".$daytextsuffix."</font>"); } else print("<font face='".$this->dayfont."' color='".$this->dayactivecolor."' size='".$this->daysize."'>".$daytextprefix." ".$daycount." ".$daytextsuffix."</font>"); } else print("<td>"); print("</td>"); $weekdaycount++; } while($weekdaycount%7<>0){ print("<td></td>"); $weekdaycount++; } print("</tr>\n </table>\n"); print("</td></tr></table>\n"); } else print("Incorrect date"); } } ?>