3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('America/New_York'); $ts = 1171502725; $date = new DateTime("@$ts"); var_dump($date->format('Y-m-d H:i:S')); $date = new DateTime; $date->modify('@' . $ts); var_dump($date->format('Y-m-d H:i:S')); $date = new DateTime; $date->setTimestamp($ts); var_dump($date->format('Y-m-d H:i:S'));
based on La40b
Output for 5.3.6 - 7.2.0
string(19) "2007-02-15 01:25:th" string(19) "2007-02-15 01:25:th" string(19) "2007-02-14 20:25:th"
Output for 5.3.0 - 5.3.5
string(19) "2007-02-15 01:25:th" string(19) "2052-06-20 18:50:th" string(19) "2007-02-14 20:25:th"
Output for 5.2.0 - 5.2.17
string(19) "2007-02-15 01:25:th" string(19) "2052-06-20 18:50:th" Fatal error: Call to undefined method DateTime::setTimestamp() in /in/F9KrH on line 14
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/F9KrH on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/F9KrH on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_default_timezone_set() in /in/F9KrH on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_default_timezone_set() in /in/F9KrH on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_default_timezone_set() in /in/F9KrH on line 3