Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are a few things I would try:</p> <p>First, Sunday == 0, <strong>not 7</strong>. Saturday == 6. and everything else between them as such.</p> <p>Set a timezone just incase you have a default set somewhere else that makes neither statement true. </p> <p>Use date_default_timezone_set() at the top of your code. I am in central time, so I would set </p> <pre><code>date_default_timezone_set('America/Chicago'); </code></pre> <p>The default can be changed in php.ini at the line "date.timezone = America/Chicago" my default before I changed it was somewhere in the UK.</p> <p>I see in a comment that you added.</p> <pre><code>if($day == 7 &amp;&amp; $m &gt;= 700 &amp;&amp; $day == 3 1125) </code></pre> <p>formatted correctly, with sunday as 0.</p> <pre><code>if($day == 0 &amp;&amp; $m &gt;= 700 &amp;&amp; $day == 3 &amp;&amp; $m &lt;= 1125) </code></pre> <p>I actually gave you a bad answer on that one at first, but I see what you're trying to do. The problem is that it will only be true from Sunday to wednesday from 700 - 1125 <strong>each day</strong>. So on Monday at 630 it would be false. The if statement isn't formatted correctly for what you want to do, but you would want to use a timestamp in your condition.</p> <p>To answer your original code. Try this:</p> <pre><code>&lt;?php date_default_timezone_set('/*ENTER YOUR TIME ZONE HERE*/ /*Find it here: http://www.php.net/manual/en/timezones.php*/'); $hour = date('G'); $minute = date('i'); $day = date('w'); $m = $hour * 60 + $minute; // Minutes since midnight. if( $day == 0 // Sunday... &amp;&amp; $m &gt;= 615 // ... after 10:15… &amp;&amp; $m &lt;= 700 // ... but before 11:40… ) header("Location: open.php"); else if( $day == 3 // Wednesday... &amp;&amp; $m &gt;= 1125 // ... after 18:45… &amp;&amp; $m &lt;= 1235 // ... but before 20:35… ) header("Location: open.php"); </code></pre> <p>Hopefully that solves your problem!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload