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.
We have two dates in mm/dd/yy
format not dd/mm/yy
so 11/30/2012
for example.
I then use the following script:
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;
}
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.
Thanks, Simon
Ref to kalvins suggestion:
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;
}
This failed on the second alert and did not alert dates.