Why doesn't this method for getting the difference between two dates work?
<p>I am trying to test whether certain time has elapsed. I use javascript. </p>

<p>Both examples use this variable:</p>

<pre><code>var delete_after = 2 /*minutes*/ * 60 /*seconds*/ * 1000/*miliseconds*/; // [miliseconds]
</code></pre>

<p>This works:</p>

<pre><code>var now = new Date();
var now_t = now.getTime();
var then = new Date(x.time); // x.time is string with a time
var then_t = then.getTime();//).getTime();
if (now_t - then_t &gt; delete_after) {
    alert("deleted");
}
</code></pre>

<p>This does not:</p>

<pre><code>if (Date().getTime() - Date(x.time).getTime() &gt; delete_after) {
    alert("deleted");
}
</code></pre>

<p>I belived them to be equivalent, but they are not. I checked precedence, in the end it appears I have to call new to create a variable. It seems to impossible to call (new Date().getTime()). Please, would You be so kind to explain why it can not be written the second way? </p>
