3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $current_day = date('N'); // Current day of the week as a number (1-7) $current_hour = date('H'); // Current hour in 24 hr format if($current_day < 6) { // Check if it's Monday - Friday if($current_hour > 6 && $current_hour < 9) { // time is between 6 and 9 AM $image = 'morning.jpg'; } elseif($current_hour > 15 && $current_hour < 17) { // time is between 3 and 5 pm $image = 'afternoon.jpg'; } elseif($current_hour > 17 && $current_hour < 21) { // time is between 5 and 9 pm $image = 'evening.jpg'; } else { // time is none of the above $image = 'unkown.jpg'; } } else { $image = 'unkown.jpg'; }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0