I had created a jquery calender by using
I have some thing like this::
Check in Date :: 21/04/2009
Check out Date :: 25/04/2009
I need to calculate the no of days between two dates?
The Result should be something like this :: 4
a little googling gave me this code:
var firstDate = new Date(2009,04,21);
var secondDate = new Date(2009,04,25);
var diffDays = Math.abs((firstDate.getTime() – secondDate.getTime())/(oneDay)); //this calculates the number of days between firstDate and secondDate
I tested it out, and it did give the answer as 4
ive done a little playing around. If you make Jquery UI to output the date as YYYY/MM/DD, then you can use this code to modify it so the maths works.
var checkOut = “2009/04/25”;
var checkOutMod = new Date(checkOut.replace(///g, “,”));
var oneDay = 24*60*60*1000;
var diffDays = Math.abs((checkInMod.getTime() – checkOutMod.getTime())/(oneDay));
You must be logged in to reply to this topic.