[EDIT]
If you are too lazy to host it yourself (or just don't have webspace), here it is (until I decide to take it off)...
http://jammersbase.ath.cx:8080/index.php
Examples using offset paramater:
http://jammersbase.ath.cx:8080/index...fset=123456789
http://jammersbase.ath.cx:8080/index...set=-123456789
[/EDIT]
Just practicing more PHP.
I noticed that PFO's calendar isn't working properly right now. It doesn't show the entire month inside the calendar, it doesn't show the remainder of the next month, and it shows too much of last month. It doesn't even show the current day as one of the days on the calendar and no other day is highlighted as the current day.
I decided to make a simulation of this calendar, In a more ... err, working form then that of PFO's.
Passing an addition "offset" paramater will offset the date by offset number of seconds.
I even included the arrow graphics for toggling the calendar on and off.
If you can see anything to improve my code (which there is probably a lot of), please suggest.
You should try it out.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ProgrammingForums.Org Calendar</title>
<style type="text/css">
table.hold {
border: 1px solid #008;
}
table.cal {
background-color: #E2DDF8;
text-align:center;
font: 11px verdana;
color: #333;
}
table.cal td {
border: 1px solid #EEE;
background-color: #EEE;
}
table.cal td.outofmnth {
border: 1px solid #E2DDF8;
background-color: #E2DDF8;
font-style: italic;
}
table.cal td.curday {
border: 1px solid #922;
font-weight: bold
}
.head {
text-align: left;
background-color: #0E68A8;
color: #FFF;
border: 1px solid #EEE;
padding: 6px;
font: 11px verdana;
font-weight: bold;
}
</style>
<script type="text/javascript">
var objects = new Array();
var type = 0;
if (document.getElementById)
{
type = 1;
}
else if (document.all)
{
type = 2;
}
else if (document.layers)
{
type = 3;
}
function get_object(idname)
{
if (typeof(objects[idname]) == "undefined")
{
if (type == 1)
{
objects[idname] = document.getElementById(idname);
}
else if (type == 2)
{
objects[idname] = document.all[idname];
}
else if (type == 3)
{
objects[idname] = document.layers[idname];
}
}
return objects[idname];
}
function hide(contID, imgID, hideurl, showurl)
{
dynobj = get_object(contID)
dynimg = get_object(imgID)
if (dynobj.style.display == "")
{
dynobj.style.display = "none";
dynimg.src = hideurl;
}
else
{
dynobj.style.display = "";
dynimg.src = showurl;
}
return false;
}
</script>
</head>
<body>
<table class="hold" cellspacing="0" cellpadding="0" border="0"><tr>
<?php
$ONEDAY = 60*60*24;
if (array_key_exists('offset', $_GET))
{
$offset = $_GET['offset'];
}
else
{
$offset = 0;
}
$curtime = time()+$offset;
$curyear = date('Y', $curtime);
$curmnth = date('F', $curtime);
$dayofwk = date('w', $curtime);
$dayofmnth = date('j', $curtime);
$nummnth = date('n', $curtime);
$begofcal = ($dayofmnth - $dayofwk) % 7 - 7;
$begtime = $curtime-($dayofmnth-$begofcal)*$ONEDAY;
$newmnth = 0;
$day = 0;
$inweek = 0;
echo '<td><div class="head">» '.$curmnth.' '.$curyear;
?>
<span onclick="return hide('calendar', 'togimg', 'http://www.programmingforums.org/forum/images/pf/buttons/collapse_tcat_collapsed.gif', 'http://www.programmingforums.org/forum/images/pf/buttons/collapse_tcat.gif')">
<img id="togimg" border="0" src="http://www.programmingforums.org/forum/images/pf/buttons/collapse_tcat.gif" alt="Toggle Calendar" title="Toggle Calendar" />
</span>
</div></td></tr>
<tr><td><table class="cal" id="calendar" cellpadding="3" cellspacing="1" border="0">
<tr><td><b>S</b></td><td><b>M</b></td><td><b>T</b></td><td><b>W</b></td><td><b>T</b></td><td><b>F</b></td><td><b>S</b></td></tr>
<?php
while(1==1)
{
$newtime = $begtime+$day*$ONEDAY;
$newnummnth = date('n', $newtime);
$newnumday = date('j', $newtime);
if ($inweek == 0)
{
echo '<tr>';
}
if ($newnummnth > $nummnth)
{
$newmnth = 1;
echo '<td class="outofmnth">';
}
elseif ($newnummnth < $nummnth)
{
echo '<td class="outofmnth">';
}
elseif ($newnumday == $dayofmnth)
{
echo '<td class="curday">';
}
else
{
echo '<td>';
}
echo $newnumday.'</td>';
$inweek ++;
$day ++;
if ($inweek == 7)
{
$inweek = 0;
echo '</tr>';
if ($newmnth == 1)
{
break;
}
}
}
?>
</table>
</td></tr></table>
</body>
</html>