note 89103 added to book.calendar
| From: | ericp at hartlandhosting dot net | Date: | Sat, 21 Feb 2009 20:45:56 +0000 |
| Subject: | note 89103 added to book.calendar | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150931@lists.php.net to get a copy of this message | ||
Simple calender
<?
#current month, maybe it could be passed in a URL
$month = 1; # January;
#current year, maybe it could be passed in a URL
$year = 2009;
if($month) {
if($year) {
$first_day = mktime(0,0,0,$month, 1, $year);
$last_day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
} else {
$first_day = mktime(0,0,0,$month, 1, date(Y));
$last_day = cal_days_in_month(CAL_GREGORIAN, $month, date(Y));
}
} else {
$first_day = mktime(0,0,0,date(m), 1, date(Y));
$last_day = cal_days_in_month(CAL_GREGORIAN, date(m), date(Y));
}
$day_of_week = date('D', $first_day);
switch($day_of_week){
case "Sun": $blank = 1; break;
case "Mon": $blank = 2; break;
case "Tue": $blank = 3; break;
case "Wed": $blank = 4; break;
case "Thu": $blank = 5; break;
case "Fri": $blank = 6; break;
case "Sat": $blank = 7; break;
}
?>
<table border=1 width="100%">
<tr>
<td>
<div align="center">Sunday</div>
</td>
<td>
<div align="center">Monday</div>
</td>
<td>
<div align="center">Tuesday</div>
</td>
<td>
<div align="center">Wednesday</div>
</td>
<td>
<div align="center">Thursday</div>
</td>
<td>
<div align="center">Friday</div>
</td>
<td>
<div align="center">Saturday</div>
</td>
</tr>
<? for($c_days = 1;$c_days <= $last_day; $c_days = $c_days + 7) { ?>
<tr>
<? for($cols = 1; $cols <= 7; $cols++) { ?>
<? if($cols < $blank && $c_days == 1) { ?>
<? } else { ?>
<? $day++; ?>
<? } ?>
<? if($day > $last_day || $day < 1) { ?>
<td>
<? echo " "; ?>
</td>
<? } else { ?>
<td>
<? echo $day; ?>
</td>
<? } ?>
<? } ?>
</tr>
<? } ?>
</table>
----
Server IP: 64.71.164.2
Probable Submitter: 75.86.201.171
----
Manual Page -- http://www.php.net/manual/en/book.calendar.php
Edit -- https://master.php.net/note/edit/89103
Del: integrated -- https://master.php.net/note/delete/89103/integrated
Del: useless -- https://master.php.net/note/delete/89103/useless
Del: bad code -- https://master.php.net/note/delete/89103/bad+code
Del: spam -- https://master.php.net/note/delete/89103/spam
Del: non-english -- https://master.php.net/note/delete/89103/non-english
Del: in docs -- https://master.php.net/note/delete/89103/in+docs
Del: other reasons-- https://master.php.net/note/delete/89103
Reject -- https://master.php.net/note/reject/89103
Search -- https://master.php.net/manage/user-notes.php