I apologize if this question has been answered. I looked everywhere and could not make this work.
as of now, my code returns the number of days like the attached example, but I would like to get the result in this format --> 1 year, 5 months, 10 days.
Is there a better way to get at this result? This is the code that I have so far, all the help would be appreciated it. Here is a bin if it helps.
function reworkedInBetweenDays(year, month, day){
var firstDate = new Date();
var secondDate = new Date(year, month-1, day);
var diffDays;
var startDate = firstDate.getTime();
var endDate = secondDate.getTime();
diffDays = (startDate - endDate) / 1000 / 86400;
diffDays = Math.round(diffDays - 0.5);
return diffDays;
}
console.log(reworkedInBetweenDays(2014,09,21));