3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dates = array( '0001-12-31', '1901-12-13', '1901-12-14', '1985-12-17', '2012-1-19', '2038-1-19', '2038-1-20', '9999-1-21', ); echo "DateTime getTimestamp() format(\"U\")\n"; foreach ($dates as $date) { $dt = new \DateTime($date); var_dump($date, $dt->getTimestamp(), $dt->format("U")); }
Output for 5.3.0 - 7.1.0
DateTime getTimestamp() format("U") string(10) "0001-12-31" int(-62104148372) string(12) "-62104148372" string(10) "1901-12-13" int(-2147559572) string(11) "-2147559572" string(10) "1901-12-14" int(-2147473172) string(11) "-2147473172" string(10) "1985-12-17" int(503622000) string(9) "503622000" string(9) "2012-1-19" int(1326927600) string(10) "1326927600" string(9) "2038-1-19" int(2147468400) string(10) "2147468400" string(9) "2038-1-20" int(2147554800) string(10) "2147554800" string(9) "9999-1-21" int(253372489200) string(12) "253372489200"
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1Wsus on line 18 DateTime getTimestamp() format("U") Fatal error: Call to undefined method DateTime::getTimestamp() in /in/1Wsus on line 19
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1Wsus on line 18 DateTime getTimestamp() format("U") Fatal error: Class 'DateTime' not found in /in/1Wsus on line 18
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1Wsus on line 18 DateTime getTimestamp() format("U") Fatal error: Cannot instantiate non-existent class: datetime in /in/1Wsus on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/1Wsus on line 18 DateTime getTimestamp() format("U") Fatal error: Cannot instantiate non-existent class: datetime in /in/1Wsus on line 18