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 ((new DateTime())->setTimestamp(strtotime('today 7am'))->setTimezone(new DateTimeZone('America/New_York')))->format('Y-m-d H:i:s');
based on egopP
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.23, 7.4.0 - 7.4.11, 8.0.0alpha1 - rc2
Current: 2020-10-18 02:28:06 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:28:06 2020-10-18 02:00:00 2020-10-17 13:00:00 2020-10-17 14:00:00 1603004400 2020-10-18 03:00:00