<?php
$today=date(jnY);
putenv('TZ=PST8PDT');
define("ADAY", (60*60*24) );
$month = $_GET['month'];
$year = $_GET['year'];
if ( ! checkdate( $month, 1, $year ) ){
	
	$nowArray = getdate();
	$month = $nowArray[mon];
	$year = $nowArray[year];
	
}
 
 echo '<pre>';
 echo print_r($nowArray);
 echo '</pre>';
 
 $start = mktime ( 0, 0, 0, $month, 1, $year );
$firstDayArray = getdate($start);
$todaysdate = getdate(mktime());

?>
<html>

 <head>


 <title><?php print "Calendar: $firstDayArray[month]
 $firstDayArray[year]" ?></title>

 </head>
 <body>
 <form action="<?= $_SERVER['PHP_SELF']; ?>" method="get">
 <select name="month">
 <?php
  $months = Array("January", "February", "March", "April",
 "May", "June", "July", "August", "September",
 "October", "November", "December");
 for ( $x=1; $x <= count( $months ); $x++ )
 {
print "\t<option value=\"$x\"";
 print ($x == $month)?" SELECTED":"";
 print ">".$months[$x-1]."\n";
 }
?>
</select>
 <select name="year">
<?php
for ( $x=1980; $x<2015; $x++ )
 {
print "\t<option";
print ($x == $year)?" SELECTED":"";
print ">$x\n";
 }
?>
 </select>
<input type="submit" value="Go!">
 </form>
<p>
 <?php
 $start_test = '';
 $days = Array("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday");
 print "<TABLE BORDER = 1 CELLPADDING=5>\n";
 foreach ( $days as $day )
 print "\t<td><b>$day</b></td>\n";
for ( $count=0; $count < (6*7); $count++ )
{
$dayArray = getdate( $start );

 if ( (($count) % 7) == 0 )
{
if ( $dayArray[mon] != $month )
break;
print "</tr><tr>\n";
 }
 if ( $count < $firstDayArray[wday] || $dayArray[mon] != $month )
 {
 print "\t<td><br></td>\n";

 }
else
{

	
print "\t<td>";

 if ($dayArray[mday]==$todaysdate[mday]&&$dayArray[mon]==$todaysdate[mon]&&$dayArray[year]==$todaysdate[year]){
	
		echo '<b>'.$dayArray[mday].'</td></b>';
		 
 } else {
	 
		echo "$dayArray[mday]</td>\n";

}

//$daymkdate = mktime(0,0,0,3,9,2011);

//$dayArray = getdate($daymkdate);$sayArray[mon] == 10 && 

if($dayArray[weekday]=='Saturday' && $dayArray[mday] == 11 && $dayArray[year] <= 2007){
	
		$start +- 90000;
			
} else {
		
		$start += ADAY;
		
}
 }
 }
 print "</tr></table>";
?>
</body>
</html>
