Find days between two dates Jquery/JS
<p>I have searched far and wide for this problem and so far none of the codes I have found failed to work and ones I have made also do the same, So I am starting to worry it isnt possible.</p>

<p>We have two dates in mm/dd/yy format not dd/mm/yy so 11/30/2012 for example</p>

<p>I then use the following script:</p>

<pre><code>        if ( jQuery("#book_room_type").val() == "La Maison" ) {
        Date.prototype.DaysBetween = function(){  
            var intMilDay = 24 * 60 * 60 * 1000;  
            var intMilDif = arguments[0] - this;  
            var intDays = Math.floor(intMilDif/intMilDay);  
            return intDays;  
        }  
        var d1 = new Date(jQuery("#dateto").val());  
        var d2 = new Date(jQuery("#datefrom").val());  
        alert("you only have".d1.DaysBetween(d2)); 

        return false;   

    }   
</code></pre>

<p>This however does not return the ammount of days between the dateto and datefrom fields, it is now driving me crazy, please any suggestions are appreciated.</p>

<p>Thanks, Simon</p>

<p>Ref to kalvins suggestion:</p>

<pre><code>        if ( jQuery("#book_room_type").val() == "La Maison" ) {
        alert("test");
        var dategap = (jQuery("#dateto").val().getTime() - jQuery("#datefrom").getTime()) / (1000 * 60 * 60 * 24);
        alert(dategap); 
        alert("test2");
        return false;   
    }   
</code></pre>

<p>This failed on the second alert and did not alert dates</p>
