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');

preferences:
65.21 ms | 402 KiB | 5 Q