Find difference in Hours between two dates in PHP

0
68

You can easily find the difference between two dates in hours/minutes/days by using PHP.

Example:


$start_date = strtotime(“2019-03-27 00:00:00”);
$end_date = strtotime(“2019-03-30 12:59:59”);
$datediff = $end_date – $start_date;

echo round($datediff / (60 * 60 * 24));

If you want to use current time then use below code.
$start_date = strtotime(“2019-03-27 00:00:00”);
$end_date = time(); // or your date as well for current timestamp
$datediff = $end_date – $start_date;

echo round($datediff / (60 * 60 * 24));

LEAVE A REPLY

Please enter your comment!
Please enter your name here