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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.