3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $curDateTime = time(); $oldDateTime = 1443530876; $curString = Date('H:i:s d/m/Y', $curDateTime); $oldString = Date('H:i:s d/m/Y', $oldDateTime); echo "curString $curString \n"; echo "oldString $oldString \n"; $date1 = new DateTime(); $date1->createFromFormat('H:i:s d/m/Y', $curString); $date2 = new DateTime(); $date2->createFromFormat('H:i:s d/m/Y', $oldString); $unix_to_date = Date('H:i:s d/m/Y', $oldDateTime); //to check the valid timestamp echo "unix_to_date $unix_to_date \n"; // var_dump($unix_to_date); var_dump($date1); var_dump($date2); ?>
based on 8Ba33
Output for 7.2.0
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.003598" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.003608" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.10
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.003137" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.003149" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.7
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.002459" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.002468" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.6
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.013366" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.013384" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.5
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.006649" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.006658" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.004031" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.004044" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30 - 5.4.45, 5.5.14 - 7.0.20
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2015-09-30 12:41:17.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.0 - 5.4.29, 5.5.0 - 5.5.13
curString 12:41:17 30/09/2015 oldString 14:47:56 29/09/2015 unix_to_date 14:47:56 29/09/2015 object(DateTime)#1 (3) { ["date"]=> string(19) "2015-09-30 12:41:17" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2015-09-30 12:41:17" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }