3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php echo date_default_timezone_get() . PHP_EOL; date_default_timezone_set('UTC'); echo '--' . PHP_EOL; $date1 = new DateTime("@1442862000"); var_dump($date1->getTimestamp()); //prints: 1442862000 echo $date1->format(DATE_RFC822 . " e T O"), "\n"; $date1->setTimezone(new DateTimeZone("Asia/Tehran")); var_dump($date1->getTimestamp()); //prints: 1442865600 echo $date1->format(DATE_RFC822 . " e T O"), "\n"; echo '--' . PHP_EOL; $next_hour = 1442865600; $date1 = new DateTime("@$next_hour"); var_dump($date1->getTimestamp()); //prints: 1442865600 echo $date1->format(DATE_RFC822 . " e T O"), "\n"; $date1->setTimezone(new DateTimeZone("Asia/Tehran")); var_dump($date1->getTimestamp()); //prints: 1442865600 echo $date1->format(DATE_RFC822 . " e T O"), "\n";
based on s38v8
Output for 7.0.20, 7.1.5 - 7.2.0
Europe/Amsterdam -- int(1442862000) Mon, 21 Sep 15 19:00:00 +0000 +00:00 GMT+0000 +0000 int(1442865600) Mon, 21 Sep 15 23:30:00 +0330 Asia/Tehran +0330 +0330 -- int(1442865600) Mon, 21 Sep 15 20:00:00 +0000 +00:00 GMT+0000 +0000 int(1442865600) Mon, 21 Sep 15 23:30:00 +0330 Asia/Tehran +0330 +0330
Output for 5.3.21 - 7.0.6, 7.1.0
Europe/Amsterdam -- int(1442862000) Mon, 21 Sep 15 19:00:00 +0000 +00:00 GMT+0000 +0000 int(1442865600) Mon, 21 Sep 15 23:30:00 +0330 Asia/Tehran IRST +0330 -- int(1442865600) Mon, 21 Sep 15 20:00:00 +0000 +00:00 GMT+0000 +0000 int(1442865600) Mon, 21 Sep 15 23:30:00 +0330 Asia/Tehran IRST +0330