title: Availability Calendar Errors on Mon 31 Mar 2014
body: <p>I am creating a page to display the availability of holiday lettings. After much learning (a newbie) I created the following code to display availability. Its objective is to display a calendar table in a line across the page and fill in booked dates (note: final version takes dates from a MySQL table).
  It works fine unless the start date is Mon 31 Mar 2014 or later. I am sure I have missed something obvious but can not work out where the error is. Any help much appreciated.</p>
  
  <pre><code>&lt;?php 
   $calendarstart = mktime(0,0,0,12,01,13);//Calendar Start as a Unix Timestamp
   $calendarend = mktime(0,0,0,5,18,14); //Calendar End as a Unix Timestamp
     echo "&lt;table border='1' width='800' cellspacing='0' cellpadding='5' align='center'&gt;
       &lt;tr&gt;
           &lt;th colspan='31' align='center' &gt;December 2013&lt;/th&gt;
           &lt;th colspan='31' align='center'&gt;January 2014&lt;/th&gt;
           &lt;th colspan='28' align='center'&gt;February 2014&lt;/th&gt;
           &lt;th colspan='31' align='center'&gt;March 2014&lt;/th&gt;
           &lt;th colspan='30' align='center'&gt;April 2014&lt;/th&gt;
           &lt;th colspan='18' align='center'&gt;May 2014&lt;/th&gt;
       &lt;/tr&gt;"; 
        echo "&lt;tr&gt;";
         for ($count=$calendarstart; $count&lt;=($calendarend); ($count=$count+86400)) // loop to add 1 day to Calendar
             {
             $startdate= (date(strtotime("Sun 30 Mar 2014"))); //Start Date from MYSQL Table Record as a Unix Timestamp      
             $enddate= (date(strtotime("Thu 10 Apr 2014"))); //End Date from MYSQL Table Record as a Unix Timestamp 
  
  
              if ($startdate==$count) // Is Recordset start date the same as the Calendar  
                {
                echo "&lt;td align='center' bgcolor='#FF0000'&gt;".date("D d ",$count)."&lt;br&gt;"; // make cell background red and write date in  
                $duration=$startdate+86400; // set variable to count duration
                $durationend=$enddate;
                }
              elseif ($duration==$count) 
                {
                    if ($duration&lt;$durationend)
                    {
                    echo "&lt;td align='center' bgcolor='#FF0000' &gt;".date("D d ",$count)."&lt;br&gt;"; // make cell background red and write date in  
                       if ($count&lt;($durationend-86400))
                       {
                       $duration=$duration+86400; // add 1 day
                       } 
                    }
  
                 }
               else
                 {
                 echo "&lt;td align='center' bgcolor='#FFFFFF'&gt;".date("D d ",$count)."&lt;br&gt;"; //make cell background white and write date in
                 } 
  
                }
       echo "&lt;/tr&gt;";
    echo "&lt;/table&gt;";
  
  ?&gt;
  </code></pre>