note 69400 added to function.date

From: Date: Tue, 05 Sep 2006 02:50:10 +0000
Subject: note 69400 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-116670@lists.php.net to get a copy of this message
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 ---- Server IP: 66.163.161.117 Probable Submitter: 203.217.21.194 (proxied: 192.168.1.87) ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/69400 Del: integrated -- https://master.php.net/note/delete/69400/integrated Del: useless -- https://master.php.net/note/delete/69400/useless Del: bad code -- https://master.php.net/note/delete/69400/bad+code Del: spam -- https://master.php.net/note/delete/69400/spam Del: non-english -- https://master.php.net/note/delete/69400/non-english Del: in docs -- https://master.php.net/note/delete/69400/in+docs Del: other reasons-- https://master.php.net/note/delete/69400 Reject -- https://master.php.net/note/reject/69400 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116670) next »