I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time.
Ultimately what I am trying to accomplish is to set up an arrival time and a departure time for the script. This is using AJAX (which I am such a newbee @) from my earlier post http://www.thescripts.com/forum/thre...3131-1-10.html
Any help is greatly appreciated.
Ultimately what I am trying to accomplish is to set up an arrival time and a departure time for the script. This is using AJAX (which I am such a newbee @) from my earlier post http://www.thescripts.com/forum/thre...3131-1-10.html
Any help is greatly appreciated.
Code:
<?
$output = '';
if($_GET[month] == '' && $$_GET[year] == '') {
$time = time();
$month = date('n',$time);
$year = date('Y',$time);
}
$date = getdate(mktime(0,0,0,$month,1,$year));
$today = getdate();
$hours = $today[hours];
$mins = $today[minutes];
$secs = $today[seconds];
if(strlen($hours)<2) $hours="0".$hours;
if(strlen($mins)<2) $mins="0".$mins;
if(strlen($secs)<2) $secs="0".$secs;
$days=date("t",mktime(0,0,0,$month,1,$year));
$start = $date[wday]+1;
$name = $date[month];
$year2 = $date[year];
$offset = $days + $start - 1;
if($month==12) {
$next=1;
$nexty=$year + 1;
} else {
$next=$month + 1;
$nexty=$year;
}
if($month==1) {
$prev=12;
$prevy=$year - 1;
} else {
$prev=$month - 1;
$prevy=$year;
}
if($offset <= 28) $weeks=28;
elseif($offset > 35) $weeks = 42;
else $weeks = 35;
$output = "<table class='daytable' cellpadding='3' cellspacing='1' align='center'>
<tr>
<td colspan='7'>
<table border='0' width='100%'>
<tr>
<td valign='middle'>
<a href='javascript:navigate($prev,$prevy)'><img src='left.gif' border='0'></a><a href='javascript:navigate(\"\",\"\")'><img src='center.gif' hspace='3' border='0'></a><a href='javascript:navigate($next,$nexty)'><img src='right.gif' border='0'></a>
</td>
<td align='right'>
<div id='heading'>$name $year2</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class='dayhead'>Sun</td>
<td class='dayhead'>Mon</td>
<td class='dayhead'>Tue</td>
<td class='dayhead'>Wed</td>
<td class='dayhead'>Thu</td>
<td class='dayhead'>Fri</td>
<td class='dayhead'>Sat</td>
</tr>";
$col=1;
$cur=1;
$next=0;
for($i=1;$i<=$weeks;$i++) {
if($next==3) $next=0;
if($col==1) $output.="<tr class='dayrow'>";
$output.="<td valign='top' class='days' onMouseOver=\"this.style.backgroundColor='#EEEEEE'\" onMouseOut=\"this.style.backgroundColor='#FFFFFF'\">";
if($i <= ($days+($start-1)) && $i >= $start) {
$output.="<div";
if(($cur==$today[mday]) && ($name==$today[month])) $output.=" style='color:#FF0000'";
$day=strtotime("$cur/$month/$year 12:00:00");
$arr = $day;
$output.="><a href=\"ajax_calendar.php?arr_date=$arr\" ><b>$cur</b></a>";
$output.="</div></td>";
$cur++;
$col++;
} else {
$output.=" </td>";
$col++;
}
if($col==8) {
$output.="</tr>";
$col=1;
}
}
$output.="</table>";
echo $output;
?>
Comment