 <p>This will give you the difference between two dates, in milliseconds</p> <pre><code>var diff = Math.abs(date1 - date2); </code></pre> <p>In your example, it'd be</p> <pre><code>var diff = Math.abs(new Date() - compareDate); </code></pre> <p>You need to make sure that compareDate is a valid Date object.</p> <p>Something like this will probably work for you</p> <pre><code>var diff = Math.abs(new Date() - new Date(dateStr.replace(/-/g,'/'))); </code></pre> <p>i.e. turning "2011-02-07 15:13:06" into new Date('2011/02/07 15:13:06'), which is a format the Date constructor can comprehend.</p> <p><a href="http://stackoverflow.com/questions/4944750/how-to-subtract-date-time-in-javascript">Answer Reference</a></p>