0

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

  • Why are `0` and `60` quoted as strings? What if `$time` is greater than `$currentTime`? Why call `date()` at all? – mickmackusa Dec 19 '20 at 14:39
  • I got help from this link : https://stackoverflow.com/questions/28424815/difference-between-specific-time-and-current-time – Sara Shafahi Dec 19 '20 at 15:04

0 Answers0