javascript: Calculate difference between two dates
<p>I want to find difference between two Dates. For that I did subtract one Date object from another Date object. My code is as follows :</p>

<pre><code>var d1 = new Date(); //"now"
var d2 = new Date(2012,3,17); // before one year
document.write("&lt;/br&gt;Currrent date : "+d1);
document.write("&lt;/br&gt;Other Date : "+d2);
document.write("&lt;/br&gt;Difference : "+new Date(Math.abs(d1-d2)));
</code></pre>

<p>But the result is not as I expected:</p>

<p><strong>Currrent date : Sun Feb 17 2013 02:58:16 GMT-0500 (EST) <br>
Other Date : Sat Jan 21 2012 00:00:00 GMT-0500 (EST)<br>
Difference : Thu Jan 28 1971 21:58:16 GMT-0500 (EST)<br></strong></p>

<p>I want to calculate the (1 year) difference between them.</p>

<p>Thanks</p>
