Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Need to calculate the no of days between two dates? Re: Need to calculate the no of days between two dates?

#56556
chazzwick
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 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));