JS: Check if date is less than 1 hour ago?
<p>Is there a way to check if a date is less than 1 hour ago?</p>

<p>Something like this:</p>

<pre><code>&lt;script&gt;
// old date
var olddate = new Date("February 9, 2012, 12:15");

// current date
var currentdate = new Date();

if (olddate &gt;= currentdate - 1 hour) {
    alert("newer than 1 hour");
else {
    alert("older than 1 hour");
}
&lt;/script&gt;
</code></pre>

<p>Also, different question - is there a way to add hours to a date?</p>

<p>Like this:</p>

<pre><code>&lt;script&gt;
var olddate = new Date("February 9, 2012, 12:15") + 15 HOURS; // output: February 10, 2012, 3:15
&lt;/script&gt;
</code></pre>
