Question and answer is powered by AnsPress.io
I have a two datetime variable like bellow
$first_date = date("2018-7-19 05:10:25"); $second_date = date("2018-7-20 10:45:25");
How can I calculate the difference between these two dates and show it as in day-hour-minute format.
$first_date = new DateTime(“2018-7-19 05:10:25”); $second_date = new DateTime(“2018-7-20 10:45:25”); $interval = $first_date->diff($second_date);
//Now show the difference of two date
echo $interval->format('%d')."d ".$interval->format('%h')."h ".$interval->format('%i')."m";