3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $end_date = "2014-09-11 20:35:10"; date_default_timezone_set('Asia/Calcutta'); $now = date('Y-m-d H:i:s'); $date1=date_create($now); $date2=date_create($end_date); $diff=date_diff($date1,$date2,FALSE); echo $diff->format("%R%d days, %h hours, %m minutes, %s seconds").PHP_EOL; $end_date = "2014-09-08 20:35:10"; date_default_timezone_set('Asia/Calcutta'); $now = date('Y-m-d H:i:s'); $date1=date_create($now); $date2=date_create($end_date); $diff=date_diff($date1,$date2,FALSE); echo $diff->format("%R%d days, %h hours, %m minutes, %s seconds").PHP_EOL;
based on JhG34
Output for 7.0.20, 7.1.5 - 7.2.0
-24 days, 18 hours, 6 minutes, 24 seconds -27 days, 18 hours, 6 minutes, 24 seconds
Output for 7.1.3
-24 days, 18 hours, 6 minutes, 23 seconds -27 days, 18 hours, 6 minutes, 23 seconds
Output for 5.4.0 - 7.0.14, 7.1.0
+2 days, 3 hours, 0 minutes, 46 seconds -0 days, 20 hours, 0 minutes, 14 seconds