3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start_time = "2017-03-20 16:30:00"; $start_mid_night = date_create_from_format("Y-m-d",explode(" ",$start_time)[0]); var_dump($start_mid_night,explode($start_time," ")[0]); $end_time = "2017-03-22 16:00:00"; $diff = strtotime(str_replace('-','/',$end_time)) - strtotime(str_replace('-','/',$start_time)); print_r( ceil(($diff)/(24*60*60)) ); echo PHP_EOL; print_r( (($diff)/(24*60*60)) );
based on F1soq
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.17.3, 7.0.0 - 7.0.16, 7.0.20 - 7.3.0beta1
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-03-20 12:13:36.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) " " 2 1.9791666666667
Output for 7.0.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2017-03-20 12:13:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } string(1) " " 2 1.9791666666667