var startdate = new Date('11/08/2014');
var enddate = new Date('03/06/2015');
function monthsBetween(date1, date2) {
var months = date2.getFullYear() * 12 + date2.getMonth() - date1.getFullYear() * 12 - date1.getMonth();
if (date2.getDate() < date1.getDate()) {
months--;
}
return months;
}
monthsBetween(startdate ,enddate)
Just find out how many months between two dates
format of date must be MM/dd/YYYY or MM-dd/YYYY
format of date must be MM/dd/YYYY or MM-dd/YYYY
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.