3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo 'date_default_timezone_get(): ' . print_r(date_default_timezone_get(), true) . "\n"; $ts = time(); echo '$ts: ' . print_r($ts, true) . "\n"; echo 'date(\'c\', $ts): ' . print_r(date('c', $ts), true) . "\n"; $datetime = new \Datetime(date('c', $ts)); echo '$datetime: ' . print_r($datetime, true) . "\n"; $datetime = new \Datetime('@' . $ts); echo '$datetime: ' . print_r($datetime, true) . "\n"; $datetime = new \Datetime('@' . $ts); $datetime->setTimezone(new \DateTimeZone(date_default_timezone_get())); echo '$datetime: ' . print_r($datetime, true) . "\n";

preferences:
32.3 ms | 407 KiB | 5 Q