3v4l.org

run code in 300+ PHP versions simultaneously
<?php $curtime = '1810'; var_dump($curtime); $trading_hour['AT_open'] = '1715'; $trading_hour['AT_close'] = '2500'; $result = 'N'; if ($curtime <= '0100' || ($curtime >= '0830' && $curtime <= '2359')) { $isOverMidnight = false; $AT_close = $trading_hour['AT_close']; if ($AT_close > '2359') { $isOverMidnight = true; $AT_close = $AT_close - '2400'; $AT_close = sprintf('%04d', $AT_close); } if ($isOverMidnight) { if ($curtime <= $AT_close || ($curtime >= $trading_hour['AT_open'] && $curtime <= '2359')) { $result = 'AT1'; } } else { if ($curtime >= $trading_hour['AT_open'] && $curtime <= $AT_close) { $result = 'AT2'; } } echo $result; } else { echo 'stop'; }
Output for 7.3.24 - 7.3.33, 7.4.12 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
string(4) "1810" AT1

preferences:
102.44 ms | 402 KiB | 114 Q