$uFrom = 1340348400; $uTo = 1340409600; $time = 1340310456; $bWork = ($uFrom <= $time and $uTo > $time) ? 1 : 0; We get 0. Why is this happening?
$uFrom = 1340348400; $uTo = 1340409600; $time = 1340310456; $bWork = ($uFrom <= $time and $uTo > $time) ? 1 : 0; We get 0. Why is this happening?
Probably because just $uFrom > $time =)
$bWork = ($uFrom <= $time && $uTo > $time) ? 1 : 0; This construction assigns a unit if ($uFrom <= $time && $uTo > $time)==true , and this construction in turn returns true only if both conditions are is true . In your case, this does not happen. You get that !($uFrom <= $time)==true , i.e. ($uFrom > $time)==true . You should use or , however, it already depends on your task.
UPD:
$c = 7; // date("H"); текущее время(в часах) for($i=1;$i<=24;$i++) // вот демонстрация для каждого часа { echo $i." => "; if($i < 4 || $i > 11) print("Open!"); else print("Close"); echo("<br>"); } Finish the algorithm to the mind or write the opposite (determine when closed), I think you will not be difficult.
$uFrom > $time 1340348400 > 1340310456
Source: https://ru.stackoverflow.com/questions/121395/
All Articles