I need help with time(), timestamp..

Discussion in 'PHP' started by CLMMafia, Dec 1, 2011.

  1. #1
    Hello,

    If its been over 1 hour since the time stamp was created I want to echo 'Error'
    but if its under 1 hour since the time stamp was created I want it to echo 'Okay'

    the only bit of code I have is

    
    $now = time();
    $timestamp = $row['timestamp'];
    
    PHP:
    Thanks.
     
    Solved! View solution.
    CLMMafia, Dec 1, 2011 IP
  2. #2
    I image your idea is when user login, system recorded time stamp is T1 and if user online over 1 hour will get message "Time out". It's right?
    Where and how did you store time stamp? I try:

    $past = time();
    // Record it to Database or use cookie/session

    Make a js script (setTimeout() function) to check active $now = time() for each 10s (maybe more if you like)

    if ($now - $past < 3600) {
         echo "Okay";
    } else {
         echo "Error";
    }
    Code (markup):
     
    kids, Dec 1, 2011 IP
  3. CLMMafia

    CLMMafia Member

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #3
    Thanks, it seam's to work.
     
    CLMMafia, Dec 1, 2011 IP