PHP IF/ELSEIF/ELSE for Day and Time
<p>I've got a piece of code on a small system I've put together for work and have got it to almost work perfectly.</p>

<p>The idea is that between 9am and 5pm, Monday to Friday it'll show a form and outside of those times it'll show a message advising them to seek help from another team.</p>

<p>It seemed to work fine today while I've been testing it by changing the times etc.. but then it didn't seem to want to work at all, I seemed to have solved it by adding '09' instead of '9' as the starting time but I've just checked the page it's being used on and the form is showing when in theory it should be the message.</p>

<p>Any ideas?</p>

<pre><code>    &lt;?php
date_default_timezone_set('Europe/London');

$day = date("l"); 
$current_hour = date("g"); 

if ($day == "Monday" &amp;&amp; $current_hour &gt;= 09 &amp;&amp; $current_hour &lt;= 17) { 
require_once('../forms/function.php');
formcraft(6); 
} 
elseif ($day == "Tuesday" &amp;&amp; $current_hour &gt;= 09 &amp;&amp; $current_hour &lt;= 17) { 
require_once('../forms/function.php');
formcraft(6); 
} 
elseif ($day == "Wednesday" &amp;&amp; $current_hour &gt;= 09 &amp;&amp; $current_hour &lt;= 17) { 
require_once('../forms/function.php');
formcraft(6); 
} 
elseif ($day == "Thursday" &amp;&amp; $current_hour &gt;= 09 &amp;&amp; $current_hour &lt;= 17) { 
require_once('../forms/function.php');
formcraft(6); 
} 
elseif ($day == "Friday" &amp;&amp; $current_hour &gt;= 09 &amp;&amp; $current_hour &lt;= 17) { 
require_once('../forms/function.php');
formcraft(6); 
} 
else 
{ 
     echo "We're not in the office right now. If your request is urgent, and by that we mean that it will have an immediate impact on our customers and/or people, please forward it to the Duty Managerwho'll know what to do."; 
} 
?&gt;
</code></pre>