3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function isMarketOpen($timestamp) { //>Wed 11:32:10 EST $timezone = new DateTimeZone('EST'); $nowDate = new DateTime((string) $timestamp, $timezone); $marketCloseTime = new DateTime('17:00:00', $timezone); $marketOpenTime = new DateTime('08:00:00', $timezone); echo $marketOpenTime->format('r'); echo "\n"; echo $nowDate->format('r'); return ($nowDate > $marketOpenTime && $nowDate < $marketCloseTime); } isMarketOpen('Wed 07:32:10 EST');
based on RgDD7
Output for 5.5.10 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Wed, 01 Oct 2014 08:00:00 -0500 Wed, 01 Oct 2014 07:32:10 -0500
Output for 5.2.0 - 5.5.9
Wed, 01 Oct 2014 08:00:00 -0400 Wed, 01 Oct 2014 07:32:10 -0500
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTimeZone' not found in /in/mEEOK on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/mEEOK on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetimezone in /in/mEEOK on line 5