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 F9KrH
Output for 5.3.6 - 7.2.0
string(19) "2007-02-15 01:25:25" string(19) "2007-02-15 01:25:25" string(19) "2007-02-14 20:25:25"
Output for 5.3.5
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:38" string(19) "2007-02-14 20:25:25"
Output for 5.3.2 - 5.3.4
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:39" string(19) "2007-02-14 20:25:25"
Output for 5.3.0 - 5.3.1
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:40" string(19) "2007-02-14 20:25:25"
Output for 5.2.16 - 5.2.17
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:38" Fatal error: Call to undefined method DateTime::setTimestamp() in /in/G4cPo on line 14
Process exited with code 255.
Output for 5.2.14 - 5.2.15
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:39" Fatal error: Call to undefined method DateTime::setTimestamp() in /in/G4cPo on line 14
Process exited with code 255.
Output for 5.2.9 - 5.2.13
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:40" Fatal error: Call to undefined method DateTime::setTimestamp() in /in/G4cPo on line 14
Process exited with code 255.
Output for 5.2.3 - 5.2.8
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:41" Fatal error: Call to undefined method DateTime::setTimestamp() in /in/G4cPo on line 14
Process exited with code 255.
Output for 5.2.0 - 5.2.2
string(19) "2007-02-15 01:25:25" string(19) "2052-12-31 02:35:42" Fatal error: Call to undefined method DateTime::setTimestamp() in /in/G4cPo on line 14
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/G4cPo 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/G4cPo 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/G4cPo 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/G4cPo 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/G4cPo on line 3