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 1401002972 which converts back to 20140525
Output for 7.0.6
20140525 gives a timestamp of 1401076438 which converts back to 20140525
Output for 7.0.5
20140525 gives a timestamp of 1401037098 which converts back to 20140525
Output for 7.0.4
20140525 gives a timestamp of 1401072968 which converts back to 20140525
Output for 7.0.3
20140525 gives a timestamp of 1400991521 which converts back to 20140525
Output for 7.0.2
20140525 gives a timestamp of 1401029122 which converts back to 20140525
Output for 7.0.1
20140525 gives a timestamp of 1401031293 which converts back to 20140525
Output for 7.0.0
20140525 gives a timestamp of 1401037629 which converts back to 20140525
Output for 5.6.21
20140525 gives a timestamp of 1401059333 which converts back to 20140525
Output for 5.6.20
20140525 gives a timestamp of 1401020091 which converts back to 20140525
Output for 5.6.19
20140525 gives a timestamp of 1401073240 which converts back to 20140525
Output for 5.6.18
20140525 gives a timestamp of 1401037111 which converts back to 20140525
Output for 5.6.17
20140525 gives a timestamp of 1401007294 which converts back to 20140525
Output for 5.6.16
20140525 gives a timestamp of 1401040380 which converts back to 20140525
Output for 5.6.15
20140525 gives a timestamp of 1401043549 which converts back to 20140525
Output for 5.6.14
20140525 gives a timestamp of 1401052594 which converts back to 20140525
Output for 5.6.13
20140525 gives a timestamp of 1401067104 which converts back to 20140525
Output for 5.6.12
20140525 gives a timestamp of 1401029248 which converts back to 20140525
Output for 5.6.11
20140525 gives a timestamp of 1401054158 which converts back to 20140525
Output for 5.6.10
20140525 gives a timestamp of 1401060929 which converts back to 20140525
Output for 5.6.9
20140525 gives a timestamp of 1400992557 which converts back to 20140525
Output for 5.6.8
20140525 gives a timestamp of 1401020847 which converts back to 20140525
Output for 5.6.7
20140525 gives a timestamp of 1401071680 which converts back to 20140525
Output for 5.5.35
20140525 gives a timestamp of 1401072336 which converts back to 20140525
Output for 5.5.34
20140525 gives a timestamp of 1401041522 which converts back to 20140525
Output for 5.5.33
20140525 gives a timestamp of 1401025899 which converts back to 20140525
Output for 5.5.32
20140525 gives a timestamp of 1401050903 which converts back to 20140525
Output for 5.5.31
20140525 gives a timestamp of 1401017534 which converts back to 20140525
Output for 5.5.30
20140525 gives a timestamp of 1401050824 which converts back to 20140525
Output for 5.5.29
20140525 gives a timestamp of 1401031431 which converts back to 20140525
Output for 5.5.28
20140525 gives a timestamp of 1401040201 which converts back to 20140525
Output for 5.5.27
20140525 gives a timestamp of 1401048509 which converts back to 20140525
Output for 5.5.26
20140525 gives a timestamp of 1401069553 which converts back to 20140525
Output for 5.5.25
20140525 gives a timestamp of 1401004624 which converts back to 20140525
Output for 5.5.24
20140525 gives a timestamp of 1401029599 which converts back to 20140525
Output for 5.4.45
20140525 gives a timestamp of 1401055454 which converts back to 20140525
Output for 5.4.44
20140525 gives a timestamp of 1401055450 which converts back to 20140525
Output for 5.4.43
20140525 gives a timestamp of 1401055445 which converts back to 20140525
Output for 5.4.42
20140525 gives a timestamp of 1401055444 which converts back to 20140525
Output for 5.4.41
20140525 gives a timestamp of 1401055441 which converts back to 20140525
Output for 5.4.40
20140525 gives a timestamp of 1401055439 which converts back to 20140525
Output for 5.4.39
20140525 gives a timestamp of 1401055437 which converts back to 20140525
Output for 5.4.38
20140525 gives a timestamp of 1401018092 which converts back to 20140525
Output for 5.4.37
20140525 gives a timestamp of 1401018085 which converts back to 20140525
Output for 5.4.35 - 5.4.36
20140525 gives a timestamp of 1401018084 which converts back to 20140525
Output for 5.4.34
20140525 gives a timestamp of 1401018083 which converts back to 20140525
Output for 5.4.32
20140525 gives a timestamp of 1400996823 which converts back to 20140525
Output for 5.4.31
20140525 gives a timestamp of 1400996822 which converts back to 20140525
Output for 5.3.29, 5.4.30
20140525 gives a timestamp of 1400996818 which converts back to 20140525
Output for 5.4.29
20140525 gives a timestamp of 1400996817 which converts back to 20140525
Output for 5.4.23 - 5.4.28
20140525 gives a timestamp of 1401002977 which converts back to 20140525
Output for 5.4.9 - 5.4.22
20140525 gives a timestamp of 1401002978 which converts back to 20140525
Output for 5.3.23 - 5.3.28, 5.4.0 - 5.4.8
20140525 gives a timestamp of 1401002979 which converts back to 20140525
Output for 5.3.8 - 5.3.22
20140525 gives a timestamp of 1401002980 which converts back to 20140525
Output for 5.3.0 - 5.3.7
20140525 gives a timestamp of 1401002981 which converts back to 20140525
Output for 5.2.10 - 5.2.17
Fatal error: Call to undefined method DateTime::createFromFormat() in /in/P5Isv on line 5
Process exited with code 255.
Output for 5.2.0 - 5.2.9
Fatal error: Call to undefined method DateTime::createfromformat() in /in/P5Isv on line 5
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/P5Isv on line 5
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/P5Isv on line 2
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/P5Isv on line 2
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/P5Isv on line 2
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/P5Isv on line 2