note 69400 deleted from function.date by bjori

From: Date: Tue, 05 Sep 2006 08:13:22 +0000
Subject: note 69400 deleted from function.date by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116677@lists.php.net to get a copy of this message
Note Submitter: anubhav83 at gmail dot com Reason: this is not a script library ---- This function will create a dynamic calender. You just need to give a month, number of days in that month and year to generate a dynamic calender. function htmlMonthCalendar($month, $days, $year) { #Numeric representation of the day of the week $firstOfMonth = date('w',mktime(0,0,0,$month,1,$year)); #full textual representation of a month, such as January or March $monthName = date('F',mktime(0,0,0,$month,1,$year)); $weekendColor = '#CCCCCC'; $calHeaderColor = '#FFFF66'; echo"<table cellspacing='0px' cellpadding='3px' border='1' style='text-align:center;'>"; echo "<tr><td colspan='7'>$monthName - $year</td></tr>"; echo"<tr style='background:$calHeaderColor'> <td style='background: $calHeaderColor'>S</td> <td style='background: $calHeaderColor'>M</td> <td style='background: $calHeaderColor'>T</td> <td style='background: $calHeaderColor'>W</td> <td style='background: $calHeaderColor'>T</td> <td style='background: $calHeaderColor'>F</td> <td style='background: $calHeaderColor'>S</td> </tr>"; echo "<tr>"; for ($i = 0; $i < $firstOfMonth; $i++) echo "<td>&nbsp;</td>"; echo "<td>1</td>"; #if firstOfMonth is saturday if($i == 7) echo "</tr>"; for ($i = 2; $i <= $days; $i++) { #Numeric representation of the day of the week $d = date("w", mktime(0,0,0,$month, $i, $year)); #if sunday, add another row if($d == 0) echo "<tr>"; #change weekend color if($d == 0 or $d == 6) echo "<td style='background:$weekendColor'>$i</td>"; else echo "<td>$i</td>"; #end of row, if saturday if($d == 6) echo"</tr>"; } echo"</table>"; } Eg: htmlMonthCalendar(9,30,2006); Anubhav

« previous php.notes (#116677) next »