I have been trying to figure out how to get between a day of week and time...I found this snippet of code:
function isBetween($from, $till, $input) {
$f = DateTime::createFromFormat('!H:i', $from);
$t = DateTime::createFromFormat('!H:i', $till);
$i = DateTime::createFromFormat('!H:i', $input);
if ($f > $t) $t->modify('+1 day');
return ($f <= $i && $i <= $t) || ($f <= $i->modify('+1 day') && $i <= $t);
};
and I have managed to get it to check between two times and see if current matches using:
if (isBetween('22:30','02:00','23:00')){
echo "true";
}
However I tried doing this
if (isBetween('22:30','02:00',date('H:i')){
but that just broke the site, I lack experience handling time and I basically want to check between 11pm monday to 2pm tuesday or 11pm monday to 5pm saturday and it has to do this check no matter what day of the year/month meaning I want it to be dynamic not static..
I've also tried:
if (date('H') < 14)
but it was very simplistic and I didn't know how to get something as complex as both date and hour+seconds