Преобразовать дни в год, месяц, дни
//Method 1
function getFormatedStringFromDays(numberOfDays) {
var years = Math.floor(numberOfDays / 365);
var months = Math.floor(numberOfDays % 365 / 30);
var days = Math.floor(numberOfDays % 365 % 30);
return [years, months, days].join(':');
}
//Method 2
const calculateTimimg = d => {
let months = 0, years = 0, days = 0;
while(d){
if(d >= 365){
years++;
d -= 365;
}else if(d >= 30){
months++;
d -= 30;
}else{
days++;
d--;
}
};
return {
years, months, days
};
};
Homely Hoopoe