3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('Asia/Calcutta'); function date_diff($start_date, $end_date) { $diff = strtotime($start_date) - strtotime($end_date); $Days = $diff/(60*60*24); $fullDays = ($now > $end_date) ? floor($Days) : ceil($Days); $Hours = ($diff-($fullDays*60*60*24))/(60*60); $fullHours = ($now > $end_date) ? floor($Hours) : ceil($Hours); $Minutes = ($diff-($fullDays*60*60*24)-($fullHours*60*60))/60; $fullMinutes = ($now > $end_date) ? floor($Minutes) : ceil($Minutes); return "Difference is $fullDays days, $fullHours hours and $fullMinutes minutes."; } $end_date = "2014-09-09 12:03:10"; $now = date('Y-m-d H:i:s'); echo date_diff($now, $end_date);
based on lWhtC
Output for 5.3.0 - 5.4.32
Fatal error: Cannot redeclare date_diff() in /in/6M0eD on line 14
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Notice: Undefined variable: now in /in/6M0eD on line 8 Notice: Undefined variable: now in /in/6M0eD on line 10 Notice: Undefined variable: now in /in/6M0eD on line 12 Difference is 1 days, -19 hours and -14 minutes.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/6M0eD 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/6M0eD 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/6M0eD 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/6M0eD on line 2