Calculate the difference between time and current time in minute

38 Views Asked by At

my question is about a field in my table that save time in format like "06:00 PM"(just show time without date with AM/PM). I want to change saved time that has not AM/PM then calculate difference time betwen that time and current time in minute, then if diference is between 60 minute echo something. for example some thing like this

$time =date("G:i", strtotime($Time_Field));
$time=strtotime($time);
$currentTime = time(); // current time
$difference = $currentTime - $time;
if( $difference > 0 && $difference < 60 )
{
echo " your request is begin in next 1 houre ";
}

My variable output is always zero even if the time interval is more than 59 minutes i test below links and this link But I was not able to calculate the difference between the time stored in the database and the current time in minutes. Thank you for your guidance

0

There are 0 best solutions below