title: Javascript time passed since timestamp
body: <p>I am trying to "cache" some information by storing it in a variable.<br />
  If 2 minutes have passed I want to get the "live" values (call the url).
  If 2 minutes have not passed I want to get the data from the variable.</p>
  
  <p>What I basicly want is: </p>
  
  <pre><code>if(time passed is less than 2 minutes) {
      get from variable
  } else {
      get from url
      set the time (for checking if 2 minutes have passed)
  }
  </code></pre>
  
  <p>I've tried calculating the time with things like</p>
  
  <pre><code>if((currentime + 2) &lt; futuretime)
  </code></pre>
  
  <p>but it wouldn't work for me.
  Anybody know how to properly check if 2 minutes have passed since the last executing of the code?</p>
  
  <p>TL;DR: Want to check if 2 minutes have passed with an IF statement.</p>