Answers for "calculate age from date of birth"

5

javascript work out age from date of birth

// To calculate age:
var year_born = prompt("Please enter your date of birth:", "Type here");
var d = new Date();
var n = d.getFullYear();
function getAge(birthYear){
	var currentDate = new Date();
    var currentYear = currentDate.getFullYear();
    age = currentYear - birthYear;
    return age;
}
calculatedAge = getAge(year_born);
alert("Hello, " + "you are " + calculatedAge + " years old!");
Posted by: Guest on November-03-2020
1

birth year calculator

// download moment.js

('#age').val( moment().diff($('#date_of_birth').val(), 'years') );
Posted by: Guest on November-01-2021
-1

calculate age

fun getAge(year: Int, month: Int, dayOfMonth: Int): Int {
    return Period.between(
                LocalDate.of(year, month, dayOfMonth),
                LocalDate.now()
            ).years
}
Posted by: Guest on October-08-2021

Code answers related to "calculate age from date of birth"

Code answers related to "Javascript"

Browse Popular Code Answers by Language