2016-02-12 44 views
0

我想在周一至周五的09:00至17:00之间播放一些内容。这是我迄今为止的,但它不起作用。在特定日期和时间显示内容

$current_time = idate('H'); 
$current_day = idate('w'); 

// Daytime - weekdays between 9am - 5pm 
if ($current_day >= 0 || $current_day <= 4 && $current_time >= 9 || $current_time <= 17) { 
     // do something 
    } 
+3

当使用'||'和''&&内部的,如果,通常最好使用括号 – kero

+0

'如果(($ CURRENT_DAY> = 0 || $ CURRENT_DAY <= 4)&&($ current_time> = 9 || $ current_time <= 17)){'〜在里面使用大括号来分隔条件 – RamRaider

回答

0

应该&&只要你想所有的人都被true白天 - 上午09点之间平日 - 下午5:00

if ($current_day >= 0 && $current_day <= 4 && $current_time >= 9 && $current_time <= 17) 
相关问题