3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startTime = "5:00AM"; $endTime = "8:00AM"; $startTime = new DateTime($startTime); $endTime = new DateTime($endTime); $now = new DateTime(); if ($now >= $startTime && $now < $endTime) { echo "Time now ({$now->format('h:i a')}) is between start ({$startTime->format('h:i a')}) and end ({$endTime->format('h:i a')}) times"; } else { echo "Time now ({$now->format('h:i a')}) is NOT between start ({$startTime->format('h:i a')}) and end ({$endTime->format('h:i a')}) times"; }
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
Time now (01:34 pm) is NOT between start (05:00 am) and end (08:00 am) times
Output for 7.3.32 - 7.3.33, 8.0.13
Time now (12:34 pm) is NOT between start (05:00 am) and end (08:00 am) times

preferences:
176.05 ms | 407 KiB | 5 Q