Home › Forums › JavaScript › Need to calculate the no of days between two dates? › Re: Need to calculate the no of days between two dates?
April 19, 2009 at 5:41 pm
#56556
Member
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.
Code:
var checkIn = “2009/04/21”;
var checkInMod = new Date(checkIn.replace(///g, “,”));
var checkInMod = new Date(checkIn.replace(///g, “,”));
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));