3v4l.org

run code in 150+ 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 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
+2 days, 3 hours, 0 minutes, 46 seconds -0 days, 20 hours, 0 minutes, 14 seconds