There are inbuilt programs for incorporating calender in to your website or blog site.But you may need to learn how to build your own calender.Here, I have displayed you very simple type of calender you can build and customized to your need.
| |||||||||||||||||||||||||||||||||||||||||||||||||
<?php $date =time () ; $day = date('d', $date) ; $month = date('m', $date) ; $year = date('Y', $date) ; $first_day = mktime(0,0,0,$month, 1, $year) ; $title = date('F', $first_day) ; $day_of_week = date('D', $first_day) ; switch($day_of_week){ case "Sun": $blank = 0; break; case "Mon": $blank = 1; break; case "Tue": $blank = 2; break; case "Wed": $blank = 3; break; case "Thu": $blank = 4; break; case "Fri": $blank = 5; break; case "Sat": $blank = 6; break; } $days_in_month = cal_days_in_month(0, $month, $year) ; echo "<table bgcolor=#138e61>"; echo "<tr bgcolor=#138e61><th colspan=7><font color=#ffffff> $title $year</font> </th></tr>"; echo "<tr bgcolor=#e8f2ee><th >Sunday</th><th >Monday</th><th >Tuesday</td><th>Wednesday</th><th>Thursday</th><th >Friday</th><th>Saturday</th></tr>"; $day_count = 1; echo "<tr bgcolor=#e8f2ee>"; while ( $blank > 0 ) { echo "<td></td>"; $blank = $blank-1; $day_count++; } $day_num = 1; while ( $day_num <= $days_in_month ) { echo "<td> $day_num </td>"; $day_num++; $day_count++; if ($day_count > 7) { echo "</tr><tr bgcolor=#e8f2ee>"; $day_count = 1; } } while ( $day_count >1 && $day_count <=7 ) { echo "<td> </td>"; $day_count++; } echo "</tr></table>"; ?> |
No comments:
Post a Comment