Calculate date difference in integer value
<p>I have two date fields with IDs gp_vdate_from and gp_vdate_to. And I have a hidden div which is populated by a dynamic table. The div gets visible on click of a button after entering date fields. I did something like this to calculate the date difference </p>

<pre><code>function parseDate(str) {
var mdy = str.split('-')
return new Date(mdy[2], mdy[0]-1, mdy[1]);
}

function daydiff(first, second) {
return Math.floor((second-first)/(1000*60*60*24))
}

var diff=(daydiff(parseDate($('#gp_vdate_from').val()), parseDate($('#gp_vdate_to').val())));
</code></pre>

<p>The date entered is in the format 10-2-2012. 
But I am not able to give to get the difference? Can someone point out why?</p>
