title: Making sure a MySQL field timestamp is not older than 1 hour of current time
body: <p>OK so I have looked at lots of similar questions on here but none seem to work. If I am short-sighted or lack the ability to search properly I apologise in advance.</p>
  
  <p>So what I need to do is check if a <code>TIMESTAMP</code>in my MySQL database i.e. 15:55:13 is no older than 1 exact hour of the current time when a script is run.</p>
  
  <p>If I have missed any needed code please let me know.</p>
  
  <p>What I have thus far:</p>
  
  <pre><code>$result = mysqli_query($link, "SELECT * 
                                 FROM web_users
                                 WHERE pass_reset_token='".$token."'
                                 AND last_pass_reset &lt; last_pass_reset
                                 INTERVAL 1 HOUR")
                                 or die(mysqli_error($link));
  </code></pre>
  
  <p>What I have tried prior:</p>
  
  <pre><code>$result = mysqli_query($link, "SELECT *
                                 FROM web_users
                                 WHERE pass_reset_token='".$token."'
                                 AND last_pass_reset &lt; NOW()-INTERVAL 1 HOUR")
                                 or die(mysqli_error($link));
  </code></pre>
  
  <p>Also:</p>
  
  <pre><code>$result = mysqli_query($link, "SELECT *
                                 FROM web_users
                                 WHERE pass_reset_token='".$token."'
                                 AND last_pass_reset &lt; DATE_SUB(CURTIME(),
                                 INTERVAL 1 HOUR)")
                                 or die(mysqli_error($link));
  </code></pre>
  
  <p>So my understanding is that I would require the match to make sure any manipulated SQL time is not less than the <strong>last_pass_reset</strong> nor greater than 1 hour.</p>
  
  <p>Thanks.</p>
  
  <p>EDIT::</p>
  
  <p>this is the updated sql query to make sure i have inputted correctly.</p>
  
  <pre><code>        // Perform a database search using the paramteres of the global variable
          $result = mysqli_query($link, "SET @scriptStartTime = CONCAT(CUR_DATE(), ' ', CUR_TIME())
                                         SELECT *
                                         FROM web_users
                                         WHERE pass_reset_token='".$token."'
                                         AND last_pass_reset &gt; DATE_SUB(@scriptStartTime, INTERVAL 1 HOUR)")
  
                                         or die(mysqli_error($link));
  </code></pre>