A time equation...

Posted on 2006-05-16
Last Modified: 2006-11-18
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.

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.

    Author Comment


    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    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 …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now