3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function date_to_unix($date){ // converts 20140526 - 1401062400 $date = DateTime::createFromFormat('Ymd', $date); return (int) $date->format('U'); } function unix_to_date($unix){ // converts 1401062400 - 20140526 $date = DateTime::createFromFormat('U', $unix); return (int) $date->format('Ymd'); } $date = date("Ymd"); echo "date $date\n"; // date 20140525 $time = time(); echo "time $time\n"; // time 1401069030 $unix = date_to_unix($date); echo "unix $unix\n"; // unix 1401069030 $date = unix_to_date($unix); echo "date $date\n"; // date 20140526
Output for 5.3.0 - 7.1.0
date 20140526 time 1401085851 unix 1401085851 date 20140526
Output for 5.2.10 - 5.2.17
date 20140526 time 1401085851 Fatal error: Call to undefined method DateTime::createFromFormat() in /in/irF0o on line 4
Process exited with code 255.
Output for 5.2.0 - 5.2.9
date 20140526 time 1401085851 Fatal error: Call to undefined method DateTime::createfromformat() in /in/irF0o on line 4
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.1 - 5.1.6
date 20140526 time 1401085851 Fatal error: Class 'DateTime' not found in /in/irF0o on line 4
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/irF0o on line 24
Process exited with code 255.
Output for 4.3.2 - 4.4.9
date 20140526 time 1401085851 Fatal error: Undefined class name 'datetime' in /in/irF0o on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
date 20140526 time 1401085851 Fatal error: Undefined class name 'datetime' in /in/irF0o on line 4