Jump to content

time in between?


takn25

Recommended Posts

Hi, I have a row in table called htime which is filled with mktime().

 

The thing I am trying to figure out is I want to echo something to the user if the time is less than 15 minutes from the current time and greater than htime (Row) for instance.

 

htime(Row)  (15 minutes in between)  time()  and when it goes over the the 15 minute mark to stop echoing.

 

I have not been successful in comparing these please any help is deeply appreciated thanks!

Link to comment
https://forums.phpfreaks.com/topic/233581-time-in-between/
Share on other sites

I'm not 100% sure that I understand your question but I'll give it a shot...

 

<?php
$htime = $row['htime'];     # Some timestamp stored in a database
$now = time();              # Current timestamp
$cutoff = $now - (15*60);   # The timestamp for 15 minutes ago

// Check that $htime is in the past, but also not more than 15 minutes ago.
if ($htime < $now && $htime > $cutoff)
{
  echo "htime was less than 15 minutes ago...";
}
?>

 

Hope that helps

Link to comment
https://forums.phpfreaks.com/topic/233581-time-in-between/#findComment-1201027
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.