title: Time difference in Nodejs?
body: <p>Im trying to figure out a way to get the time difference in seconds between two dates.</p>
  
  <p>For example, difference in seconds between:</p>
  
  <pre><code>2013-5-11 8:37:18
  
  2013-5-11 10:37:18
  </code></pre>
  
  <p>Tried:</p>
  
  <pre><code>function timeDifference(laterdate, earlierdate) {
      var difference = laterdate.getTime() - earlierdate.getTime();
      var daysDifference = Math.floor(difference/1000/60/60/24);
      difference -= daysDifference*1000*60*60*24
      var hoursDifference = Math.floor(difference/1000/60/60);
      difference -= hoursDifference*1000*60*60
      var minutesDifference = Math.floor(difference/1000/60);
      difference -= minutesDifference*1000*60
      var secondsDifference = Math.floor(difference/1000);
  
      return secondsDifference;
  }
  </code></pre>
  
  <p>But that does not work in Nodejs, error with </p>
  
  <blockquote>
    <p>getTime()</p>
  </blockquote>
  
  <p>function not being found</p>