Inputs Needed
- Date
- Month
- Year
Outputs
How long you have been living.
- In Months
- Indays
- In Minutes
And How many days remaining for your next birthday.
- var startyear = "1950";
- var endyear = "2010";
- var ddlday = document.getElementById("ddlday");
- var ddlmonth = document.getElementById("ddlmonth");
- var ddlyears = document.getElementById("ddlyears");
- var dayop = "";
- var monthop = "";
- var yearop = "";
-
- for (var j = 1; j < 32; j++) {
- dayop += "<option value=" + j + ">" + j + "</option>";
- }
- ddlday.innerHTML = dayop;
-
- for (var j = 1; j < 13; j++) {
- monthop += "<option value=" + j + ">" + j + "</option>";
- }
- ddlmonth.innerHTML = monthop;
-
- for (var k = startyear; k < endyear; k++) {
- yearop += "<option value=" + k + ">" + k + "</option>";
- }
- ddlyears.innerHTML = yearop;
-
-
-
- function checkleapyear(datea) {
- if (datea.getYear() % 4 == 0) {
- if (datea.getYear() % 10 != 0) {
- return true;
- } else {
- if (datea.getYear() % 400 == 0)
- return true;
- else
- return false;
- }
- }
- return false;
- }
-
- function DaysInMonth(Y, M) {
- with(new Date(Y, M, 1, 12)) {
- setDate(0);
- return getDate();
- }
- }
-
- function datediff(date1, date2) {
- var y1 = date1.getFullYear(),
- m1 = date1.getMonth(),
- d1 = date1.getDate(),
- y2 = date2.getFullYear(),
- m2 = date2.getMonth(),
- d2 = date2.getDate();
- if (d1 < d2) {
- m1--;
- d1 += DaysInMonth(y2, m2);
- }
- if (m1 < m2) {
- y1--;
- m1 += 12;
- }
- return [y1 - y2, m1 - m2, d1 - d2];
- }