3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $dateTime = new DateTime('2008-09-22'); echo $dateTime->format('U'); echo PHP_EOL; $date = DateTime::createFromFormat('d-m-Y', '22-09-2008'); echo $date->format('U');
Output for 5.6.28, 7.0.14 - 7.1.0
1222034400 1222099026
Output for 7.0.6
1222034400 1222109212
Output for 5.5.34, 5.6.19 - 5.6.20, 7.0.5
1222034400 1222098844
Output for 5.5.32 - 5.5.33, 5.6.17 - 5.6.18, 7.0.3 - 7.0.4
1222034400 1222098845
Output for 5.5.31, 5.6.15 - 5.6.16, 7.0.0 - 7.0.2
1222034400 1222098846
Output for 5.6.21
1222034400 1222115773
Output for 5.5.29 - 5.5.30, 5.6.13 - 5.6.14
1222034400 1222098847
Output for 5.5.26 - 5.5.28, 5.6.11 - 5.6.12
1222034400 1222098848
Output for 5.5.25, 5.6.9 - 5.6.10
1222034400 1222098849
Output for 5.5.23 - 5.5.24, 5.6.7 - 5.6.8
1222034400 1222098850
Output for 5.5.21 - 5.5.22, 5.6.5 - 5.6.6
1222034400 1222098851
Output for 5.5.18 - 5.5.20, 5.6.3 - 5.6.4
1222034400 1222098852
Output for 5.5.16, 5.6.0 - 5.6.2
1222034400 1222098853
Output for 5.5.35
1222034400 1222081988
Output for 5.5.13 - 5.5.15
1222034400 1222098854
Output for 5.5.9 - 5.5.12
1222034400 1222098855
Output for 5.5.6 - 5.5.8
1222034400 1222098856
Output for 5.5.3 - 5.5.5
1222034400 1222098857
Output for 5.5.0 - 5.5.2
1222034400 1222098858
Output for 5.4.0 - 5.4.45
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone.' in /in/o8XIr:2 Stack trace: #0 /in/o8XIr(2): DateTime->__construct('2008-09-22') #1 {main} thrown in /in/o8XIr on line 2
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead' in /in/o8XIr:2 Stack trace: #0 /in/o8XIr(2): DateTime->__construct('2008-09-22') #1 {main} thrown in /in/o8XIr on line 2
Process exited with code 255.
Output for 5.2.10 - 5.2.17
1222034400 Fatal error: Call to undefined method DateTime::createFromFormat() in /in/o8XIr on line 7
Process exited with code 255.
Output for 5.2.3 - 5.2.9
1222034400 Fatal error: Call to undefined method DateTime::createfromformat() in /in/o8XIr on line 7
Process exited with code 255.
Output for 5.2.0 - 5.2.2
1222034400 <br /> <b>Fatal error</b>: Call to undefined method DateTime::createfromformat() in <b>/in/o8XIr</b> on line <b>7</b><br />
Process exited with code 255.
Output for 5.0.0 - 5.1.6
<br /> <b>Fatal error</b>: Class 'DateTime' not found in <b>/in/o8XIr</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.4.9
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: datetime in <b>/in/o8XIr</b> on line <b>2</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<br /> <b>Fatal error</b>: Cannot instantiate non-existent class: datetime in <b>/in/o8XIr</b> on line <b>2</b><br />