I'm trying to calculate the age of the user in months, days, hours and minutes including leap years.. However, rather than using the select/option in HTML, I've input the options via Javascript. Due to this, I'm rather confused on how to do the calculations in Javascript now. Could anyone point me in the right direction to do these calculations?
HTML :
` <ul class = "mainList">
<h1>
Age Calculator
</h1>
<h2> Enter Your Birthday</h2>
<li class = "firstList">
<p class = "datePara">
Date:
</p>
<select id = "day">
</select>
</li>
<li>
<p class = "monthPara">
Month:
</p>
<select id = "month">
</select>
</li>
<li>
<p class = "yearPara">
Year:
</p>
<select id = "year">
</select>
</li>
</ul>`
Javascript : `
var startyear = "1950";
var endyear = "2015";
var dat = new date();
var curday = dat.getDate();
var curmon = dat.getMonth() + 1;
var curyear = dat.getFullYear();
function initForm() {
document.getElementById('day').focus();
for (var i = 1; i <= 31; i ++) {
var thisDay = document.getElementById('day');
var dayOption = document.createElement('option');
dayOption.text = i;
thisDay.add(dayOption, i);
}
for (var i = 1; i <= 12; i ++) {
var thisMonth = document.getElementById('month');
var monthOption = document.createElement('option');
monthOption.text = i;
thisMonth.add(monthOption, i);
}
for (var i = startyear; i <= endyear; i ++) {
var thisYear = document.getElementById('year');
var yearOption = document.createElement('option');
yearOption.text = i;
thisYear.add(yearOption, i);
}
}`