title: How to get time difference between two timestamps in seconds with jQuery?
body: <p>I want to display <code>x seconds ago</code> based on a MySQL Timestamp.</p>
  
  <p>I found the plugin called <a href="http://timeago.yarp.com/" rel="noreferrer">timeago</a></p>
  
  <p>But I cannot find a way to make it display only seconds.</p>
  
  <p>I'm OK with 61 seconds, or 300 seconds. Any way to convert the output to seconds with timeago, or with pure jQuery / JavaScript ?</p>
  
  <p>Thanks for any help !</p>
  
  <h2>Edit:</h2>
  
  <p><strong>Sample Case :</strong></p>
  
  <pre><code>$time1 = "2014-02-02 23:54:04"; // plus PHP ways to format it.
  //$time2 = NOW() , or date(); whatever. 
  </code></pre>
  
  <p>I just want to get how many seconds since <code>$time1</code>.</p>
  
  <h2>Edit 2:</h2>
  
  <p>Working code : </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(function(){
      var d2 = new Date();
      var d1 = new Date("2014-02-02 23:54:04");
      $("a#timedif").html("Diff. Seconds : "+((d2-d1)/100).toString());
      // note that you may want to round the value
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>It outputs <code>Diff. Seconds : NaN</code></p>