3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $time_intervals = "00:00-23:59"; $time_to_check = "2014-05-08 23:58:00"; $time_intervals = preg_split('/[\;]+/', $time_intervals); //separates the intervals by ; $time_valid = false; $i = 0; $time_to_check = strtotime(date('H:i', strtotime($time_to_check))); foreach ($time_intervals as $time_interval): $time = preg_split('/[\-]+/', $time_interval); if (($time_to_check >= strtotime($time[0])) && ($time_to_check <= strtotime($time[1]))): $time_valid = true; endif; endforeach; var_dump($time_valid); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
bool(true)