2016-02-12 53 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)