3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('America/New_York'); function date_to_unix($date){ $date = DateTime::createFromFormat('Ymd', $date); return $date->getTimestamp(); } function unix_to_date($unix){ $date = DateTime::createFromFormat('U', $unix); $date->setTimezone(new \DateTimeZone(date_default_timezone_get())); return $date->format('Ymd'); } $originalDate = '20140525'; $timeStamp = date_to_unix($originalDate); $newDate = unix_to_date($timeStamp); echo "$originalDate gives a timestamp of $timeStamp which converts back to $newDate";
Output for 5.6.28, 7.0.14 - 7.1.0
20140525 gives a timestamp of 1401002959 which converts back to 20140525
Output for 7.0.6
20140525 gives a timestamp of 1401004615 which converts back to 20140525
Output for 7.0.5
20140525 gives a timestamp of 1401050839 which converts back to 20140525
Output for 7.0.4
20140525 gives a timestamp of 1401002477 which converts back to 20140525
Output for 7.0.3
20140525 gives a timestamp of 1401008354 which converts back to 20140525
Output for 7.0.2
20140525 gives a timestamp of 1401029563 which converts back to 20140525
Output for 7.0.1
20140525 gives a timestamp of 1401046586 which converts back to 20140525
Output for 7.0.0
20140525 gives a timestamp of 1401052150 which converts back to 20140525
Output for hhvm-3.12.0
20140525 gives a timestamp of 1401012681 which converts back to 20140525
Output for hhvm-3.10.0
20140525 gives a timestamp of 1401010384 which converts back to 20140525
Output for 5.6.21
20140525 gives a timestamp of 1401074281 which converts back to 20140525
Output for 5.6.20
20140525 gives a timestamp of 1401047066 which converts back to 20140525
Output for 5.6.19
20140525 gives a timestamp of 1401031747 which converts back to 20140525
Output for 5.6.18
20140525 gives a timestamp of 1401064138 which converts back to 20140525
Output for 5.6.17
20140525 gives a timestamp of 1401023644 which converts back to 20140525
Output for 5.6.16
20140525 gives a timestamp of 1401054859 which converts back to 20140525
Output for 5.6.15
20140525 gives a timestamp of 1401058781 which converts back to 20140525
Output for 5.6.14
20140525 gives a timestamp of 1401067224 which converts back to 20140525
Output for 5.6.13
20140525 gives a timestamp of 1400994891 which converts back to 20140525
Output for 5.6.12
20140525 gives a timestamp of 1401044393 which converts back to 20140525
Output for 5.6.11
20140525 gives a timestamp of 1401069841 which converts back to 20140525
Output for 5.6.10
20140525 gives a timestamp of 1401076062 which converts back to 20140525
Output for 5.6.9
20140525 gives a timestamp of 1401007541 which converts back to 20140525
Output for 5.6.8
20140525 gives a timestamp of 1401036746 which converts back to 20140525
Output for 5.5.35
20140525 gives a timestamp of 1401001531 which converts back to 20140525
Output for 5.5.34
20140525 gives a timestamp of 1401055516 which converts back to 20140525
Output for 5.5.33
20140525 gives a timestamp of 1401042368 which converts back to 20140525
Output for 5.5.32
20140525 gives a timestamp of 1401070040 which converts back to 20140525
Output for 5.5.31
20140525 gives a timestamp of 1401033591 which converts back to 20140525
Output for 5.5.30
20140525 gives a timestamp of 1401065737 which converts back to 20140525
Output for 5.5.29
20140525 gives a timestamp of 1401045619 which converts back to 20140525
Output for 5.5.28
20140525 gives a timestamp of 1401055603 which converts back to 20140525
Output for 5.5.27
20140525 gives a timestamp of 1401064474 which converts back to 20140525
Output for 5.5.26
20140525 gives a timestamp of 1400998476 which converts back to 20140525
Output for 5.5.25
20140525 gives a timestamp of 1401021163 which converts back to 20140525
Output for 5.5.24
20140525 gives a timestamp of 1401047636 which converts back to 20140525
Output for 5.4.45
20140525 gives a timestamp of 1401055453 which converts back to 20140525
Output for 5.4.44
20140525 gives a timestamp of 1401055449 which converts back to 20140525
Output for 5.4.43
20140525 gives a timestamp of 1401055444 which converts back to 20140525
Output for 5.4.42
20140525 gives a timestamp of 1401055442 which converts back to 20140525
Output for 5.4.41
20140525 gives a timestamp of 1401055440 which converts back to 20140525
Output for 5.4.40
20140525 gives a timestamp of 1401055438 which converts back to 20140525
Output for 5.4.39
20140525 gives a timestamp of 1401055436 which converts back to 20140525
Output for 5.4.38
20140525 gives a timestamp of 1401073066 which converts back to 20140525
Output for 5.4.37
20140525 gives a timestamp of 1401073059 which converts back to 20140525
Output for 5.4.35 - 5.4.36
20140525 gives a timestamp of 1401073058 which converts back to 20140525
Output for 5.4.34
20140525 gives a timestamp of 1401073057 which converts back to 20140525
Output for 5.4.32
20140525 gives a timestamp of 1401048751 which converts back to 20140525
Output for 5.4.31
20140525 gives a timestamp of 1401048749 which converts back to 20140525
Output for 5.3.29, 5.4.30
20140525 gives a timestamp of 1401048746 which converts back to 20140525
Output for 5.4.29
20140525 gives a timestamp of 1401048745 which converts back to 20140525
Output for 5.4.20 - 5.4.28
20140525 gives a timestamp of 1401002963 which converts back to 20140525
Output for 5.4.10 - 5.4.19
20140525 gives a timestamp of 1401002964 which converts back to 20140525
Output for 5.3.25 - 5.3.28, 5.4.0 - 5.4.9
20140525 gives a timestamp of 1401002965 which converts back to 20140525
Output for 5.3.12 - 5.3.24
20140525 gives a timestamp of 1401002966 which converts back to 20140525
Output for 5.3.1 - 5.3.11
20140525 gives a timestamp of 1401002967 which converts back to 20140525
Output for 5.3.0
20140525 gives a timestamp of 1401002968 which converts back to 20140525
Output for 5.2.10 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Call to undefined method DateTime::createFromFormat() in /in/vD5ll on line 5
Process exited with code 255.
Output for 5.2.0 - 5.2.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Call to undefined method DateTime::createfromformat() in /in/vD5ll on line 5
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Class 'DateTime' not found in /in/vD5ll on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Call to undefined function date_default_timezone_set() in /in/vD5ll on line 2
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Call to undefined function: date_default_timezone_set() in /in/vD5ll on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Call to undefined function: date_default_timezone_set() in /in/vD5ll on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/vD5ll on line 11 Fatal error: Call to undefined function: date_default_timezone_set() in /in/vD5ll on line 2