I want to get the difference between 2 dates in days months and years. The problem is that because there is not a set amount of days to any Month, I can't figure out how I can compare 2 dates with Months that are between 28 and 31 days. I have done it for Years and Months, because I know there are 12 Months to a year, so I can calculate it. Maybe someone knows a method of getting round this. here's what I have so far. Thanks for reading.
var date1 = new Date(2013,10,1);
var date2 = new Date();
var y1 = date1.getFullYear();
var m1 = date1.getMonth();
var y2 = date2.getFullYear();
var m2 = date2.getMonth();
var totDiff = (y1 - y2) * 12 + (m1 - m2 -1);
var yDiff = Math.floor(Math.abs(totDiff) / 12);
var mDiff = totDiff - (Math.floor((totDiff) / 12) * 12);
console.log("years: " + yDiff + " months: " + mDiff);