I have two date pickers that calculates the number of days there are between the two dates. At the moment I\'m outputting the number of days (see code below) which is kind o
Considering
1 Year => 365 Days
1 MONTH => 30 Days
1 WEEK => 7 Days
value => NUMBER OF DAYS
function parseDays (value)
{
var year, months, week, days;
year = value >= 365 ? Math.floor(value / 365) : 0;
value = year ? value - (year*365) : value;
months = value >= 30 ? Math.floor((value % 365) / 30) : 0;
value = months ? value - (months*30) : value;
week = value >= 7 ? Math.floor((value % 365) / 7) : 0;
value = week ? value - (week*7) : value;
days = value < 7 ? Math.floor((value % 365) % 7) : 0;
console.log("years = ", year);
console.log("months = ",months);
console.log("weeks = ",week);
console.log("days = ", days);
}