3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); $b = new DateTime(); echo "Current: ".$b->format('Y-m-d H:i:s'); echo "\r\n"; echo "\r\n"; $t = new DateTime("07:00", new DateTimeZone('America/New_York')); $t->setTimezone(new DateTimeZone('UTC')); echo "ET: ".$t->format('Y-m-d H:i:s'); $f = (new DateTime())->setTimezone(new DateTimeZone('America/New_York')); $f->setTime(7,0); $f->setTimezone(new DateTimeZone('UTC')); echo "\r\n"; echo "ET Second Way: ".$f->format('Y-m-d H:i:s'); echo "\r\n"; $t = new DateTime("07:00", new DateTimeZone('America/Chicago')); $t->setTimezone(new DateTimeZone('UTC')); echo "ET: ".$t->format('Y-m-d H:i:s'); $f = (new DateTime())->setTimezone(new DateTimeZone('America/Chicago')); $f->setTime(7,0); $f->setTimezone(new DateTimeZone('UTC')); echo "\r\n"; echo "ET Second Way: ".$f->format('Y-m-d H:i:s'); echo "\r\n"; $t = new DateTime("07:00", new DateTimeZone('America/Denver')); $t->setTimezone(new DateTimeZone('UTC')); echo "ET: ".$t->format('Y-m-d H:i:s'); $f = (new DateTime())->setTimezone(new DateTimeZone('America/Denver')); $f->setTime(7,0); $f->setTimezone(new DateTimeZone('UTC')); echo "\r\n"; echo "ET Second Way: ".$f->format('Y-m-d H:i:s'); echo "\r\n"; $t = new DateTime("07:00", new DateTimeZone('America/Los_Angeles')); $t->setTimezone(new DateTimeZone('UTC')); echo "ET: ".$t->format('Y-m-d H:i:s'); $f = (new DateTime())->setTimezone(new DateTimeZone('America/Los_Angeles')); $f->setTime(7,0); $f->setTimezone(new DateTimeZone('UTC')); echo "\r\n"; echo "ET Second Way: ".$f->format('Y-m-d H:i:s'); echo "\r\n---"; $f = new DateTime("07:00", new DateTimeZone('America/Chicago')); $f->setTimezone(new DateTimeZone('UTC')); echo $f->format('Y-m-d H:i:s'); echo "\r\n"; echo "\r\n"; $f = new DateTime(); $f->setTimezone(new DateTimeZone('America/Chicago')); echo $f->format('Y-m-d H:i:s'); $f = new DateTime(); $f->setTime(7,0); echo "\r\n"; $f->setTimezone(new DateTimeZone('America/Chicago')); echo $f->format('Y-m-d H:i:s'); echo "\r\n"; echo "\r\n"; $g = new DateTime("07:00", new DateTimeZone('America/Denver')); $g->setTimezone(new DateTimeZone('UTC')); echo $g->format('Y-m-d H:i:s'); echo "\r\n"; $h = new DateTime("07:00", new DateTimeZone('America/Los_Angeles')); $h->setTimezone(new DateTimeZone('UTC')); echo $h->format('Y-m-d H:i:s'); echo "\r\n"; echo strtotime('today 7am'); echo "\r\n"; echo (DateTime::createFromFormat('Y-m-d H:i:s', strtotime('today 7am')))->format('Y-m-d H:i:s');
based on Ak53i
Output for 7.3.0 - 7.3.23, 7.4.0 - 7.4.11, 8.0.0alpha1 - rc2
Current: 2020-10-18 02:24:58 ET: 2020-10-17 11:00:00 ET Second Way: 2020-10-17 11:00:00 ET: 2020-10-17 12:00:00 ET Second Way: 2020-10-17 12:00:00 ET: 2020-10-17 13:00:00 ET Second Way: 2020-10-17 13:00:00 ET: 2020-10-17 14:00:00 ET Second Way: 2020-10-17 14:00:00 ---2020-10-17 12:00:00 2020-10-17 21:24:58 2020-10-18 02:00:00 2020-10-17 13:00:00 2020-10-17 14:00:00 1603004400 Fatal error: Uncaught Error: Call to a member function format() on bool in /in/AKq75:79 Stack trace: #0 {main} thrown in /in/AKq75 on line 79
Process exited with code 255.
Output for 7.2.0 - 7.2.34
Current: 2020-10-18 02:24:58 ET: 2020-10-17 11:00:00 ET Second Way: 2020-10-17 11:00:00 ET: 2020-10-17 12:00:00 ET Second Way: 2020-10-17 12:00:00 ET: 2020-10-17 13:00:00 ET Second Way: 2020-10-17 13:00:00 ET: 2020-10-17 14:00:00 ET Second Way: 2020-10-17 14:00:00 ---2020-10-17 12:00:00 2020-10-17 21:24:58 2020-10-18 02:00:00 2020-10-17 13:00:00 2020-10-17 14:00:00 1603004400 Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/AKq75:79 Stack trace: #0 {main} thrown in /in/AKq75 on line 79
Process exited with code 255.