检查时间是否介于两次之间

I have a deal which is available on every Friday from 22:00 to 4:00. But the problem is that after 00:00 it will turn to Saturday and my code will no longer find the deal.

Here is how I save the deals:

Array
(
    [0] => Array
        (
            [offerAvailableOn] => 5
            [open] => 22:00 
            [close] =>  04:00
        )
}

And this is my code to query for it:

$today = date('N');
$timeNow = date('H:i');

But when $today is Saturday, it won't find my offer.

You can make your open and close variables to include the day of the week. Have a look at this page of the manual:

http://php.net/manual/en/datetime.formats.relative.php

So open could be 'Friday 22:00' en close could be 'Saturday 04:00'. In PHP that would look like this:

$deal = array('open'  => 'Friday 22:00',
              'close' => 'Saturday 04:00');

echo 'deal open: '.date('Y-m-d H:i:s', strtotime($deal['open'])).'<br>';
echo 'deal close: '.date('Y-m-d H:i:s', strtotime($deal['close']));

For me this gives now:

deal open: 2014-10-24 22:00:00
deal close: 2014-10-18 04:00:00

Notice that the deal open time is bigger that the current time. So you have to think about your if conditions:

$open  = strtotime($deal['open']);
$close = strtotime($deal['close']);
$now   = time();

$dealIsOn = (($open > $now) && ($close < $now));

Which might seem counter-intuitive at first, but is correct.

Also notice that this system is quite flexible. With the same code you can select a day of the month. However, for a absolute dates you have to do another check:

$open  = strtotime('2014-10-25 22:00:00');
$close = strtotime('2014-10-26 22:00:00');
$now   = time();

$dealIsOn = (($open < $now) && ($close > $now));

So I would introduce a flag in the array indicating whether or not the open and close variables are absolute or relative.

Change it to two tests. The offer is available Friday at 22:00 or later and Saturday at 4:00 or earlier.