3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/Toronto'); $start_day = 'tue'; $start_time = 181300; $end_day = 'fri'; $end_time = 134500; $startDate = DateTime::createFromFormat ( 'D His', $start_day . ' '. $start_time); $endDate = DateTime::createFromFormat ( 'D His', $end_day . ' '. $end_time); $startHour = $startDate->format('G'); //24-hour format of an hour without leading zeros $startDay = $startDate->format('N'); //numeric representation of the day of the week $endHour = $endDate->format('G'); //24-hour format of an hour without leading zeros $endDay = $endDate->format('N'); //numeric representation of the day of the week //We Need to check the time is between Tuesday 6PM ( 2 and 18 for $startDay and $startHour respectively ) to Friday 6PM ( ( 5 and 18 for $endDay and $endHour respectively )) if ( $startDay >= 2 && $endDay <= 5 && $startHour >= 18 and $endHour <= 18 ) { echo 'Within Time Range'; } else { echo 'Outside Range'; }
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
Within Time Range
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Within Time Range

preferences:
187.5 ms | 402 KiB | 178 Q