title: Javascript - Subtracting Date and Time
body: <p>I am trying to figure out how to subtrack time. My #1 goal is to find out if a date and time has past the current date and time. I have posted another question on this but not have not got an answer or maybe i'm just not doing what they were telling me correctly. </p>
  
  <p>I've been experimenting with this:</p>
  
  <p><strong>Returned Value for Below script...</strong><br/>
  CookieTime Values = 8/16/2012 12:34:00 AM<br/>
  CookieTime = 0<br/>
  Parsed Date = 946702800000<br/>
  currTime = 8-18-2012 1345311956215<br/>
  CookieTime - currTime = NaN<br/></p>
  
  <pre><code>document.write('CookieTime Values = ' + reminders[0].reminderdate + ' ' + reminders[0].remindertime + '&lt;br/&gt;'); // = 8/16/2012 12:34:00 AM
  var CookieTime = new Date(reminders[0].reminderdate &amp; ' ' &amp; reminders[0].remindertime);
  CookieTime = CookieTime.getTime()
  
  document.write('CookieTime = ' + CookieTime + '&lt;br/&gt;'); // = 0
  document.write('Parsed Date = ' + Date.parse(CookieTime)  + '&lt;br/&gt;'); // = 946702800000
  
  var currDate = new Date();
  var currDate = currDate.getMonth() + 1 + "-" + currDate.getDate() + "-" + currDate.getFullYear();
  
  var currTime = new Date();
  currTime = currDate + ' ' + currTime.getTime();
  document.write('currTime = ' + currTime + '&lt;br/&gt;'); // = 8-18-2012 1345410601357
  
  document.write('CookieTime - currTime = ' + CookieTime - currTime + '&lt;br/&gt;'); // = NaN
  </code></pre>