Solved

# A time equation...

Posted on 2006-05-16
176 Views
Here is what my project calls for... I will need to compare a time (hour min sec) retrieved from the database to the current time and figure out if the new time is newer by five or more minutes as the start of an if statement. In other words, if the current time is five minutes later than the old time (from the server (mysql)) then....

I have played with mktime, but I get a string of numbers I am not sure what to do with.

Thanks.
0
Question by:cbonnock

LVL 5

Accepted Solution

// convert to a unix timestamp
\$database_date = strtotime(\$database_date);

if (time() >= strtotime('+5 minutes', \$database_date))
{
// 5+ minutes have passed since the database date
}

Note that, since you're dealing with minutes (always the same length), you could also do:

if (time() >= (\$database_date + (5 * 60)))

And save yourself a function call. The time interval is just a little more obfuscated that way.
0

Author Comment

Thanks.
0

## Featured Post

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …