I am trying to get the difference between two dates in Years, months, days. I've tried everything I know so far but so far I am not getting what I was tending to get.
This is my last try, the problem with it is that I am getting 5 years converted into months and days instead of getting the difference in years left, months left and days,
button.addEventListener('click',()=>{
let m = moment(selectDate.value);
let applyingDate = m.add(5,"years");
let cur = moment();
let diff = applyingDate - cur;
let years = Math.floor(diff/(1000*60*60*24)/365);
let months = Math.floor(diff/(1000*60*60*24)/365/12);
let days = Math.floor(diff/(1000*60*60*24)/30);
console.log(years,months,days);
});
any help, please ? An explanation of the concept would be so much appreciated <3