3v4l.org

run code in 300+ PHP versions simultaneously
<?php $current_day = date('N'); // Current day of the week as a number (1-7) - Sunday is first day of the week $current_hour = date('H'); // Current hour in 24 hr format if($current_day < 6) { // Check if it's Monday - Friday if($current_hour > 01 && $current_hour < 09) { // time is between 1 and 9 AM--> echo "123"; } elseif($current_hour > 09 && $current_hour < 18) { // time is between 9 am and 6 pm--> echo "456"; } elseif($current_hour > 18 && $current_hour < 23) { // time is between 6 pm and 11 pm--> echo "789"; } else { // time is none of the above--> echo "101112"; } } else { // EVERYTHING ELSE--> echo "131415"; }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
456

preferences:
252.8 ms | 1397 KiB | 200 Q