How to calculate minute difference between two date-times in PHP?
I found so many solution but I never got correct solution. But i have created some code to find minutes please check it.
= $mins1) {
$mins = $mins2 - $mins1;
}
else {
$mins = ($mins2 + 60) - $mins1;
$hours--;
}
if($mins < 9)
{
$mins = str_pad($mins, 2, '0', STR_PAD_LEFT);
}
if($hours < 9)
{
$hours =str_pad($hours, 2, '0', STR_PAD_LEFT);
}
echo $hours.':'.$mins;
?>
It gives output in hours and minutes for example 01 hour 02 minutes like 01:02