Reputation: 13
I want to set $a = 5
between 09.00h and 16.59h, Monday to Friday.
$time = time()%86400;
if( (date("D") == "Mon") || (date("D") == "Tue") || (date("D") == "Wed") ||
(date("D") == "Thu") || (date("D") == "Fri") && $time >= 32400 && $time <= 61119){
$a = 5;
}
Have does the && time read at the end? Does it read "Mon OR Tue OR Wed OR Thu OR Fri..." AND "Time...", or instead "Fri AND Time"?
Upvotes: 1
Views: 60
Reputation: 37361
You're close, you'll need a set of parenthesis around the ORs, but a slightly cleaner way to write this might be:
if( in_array((date("D"), array("Mon","Tue","Wed","Thu","Fri"))
&& $time >= 32400 && $time <= 61119 ){
or even:
!in_array((date("D"), array("Sat","Sun"))
Upvotes: 1