Answers for "age calculator from birthday"

C#
0

How do I calculate someone's age based on a DateTime type birthday?

// Save today's date.
var today = DateTime.Today;

// Calculate the age.
var age = today.Year - birthdate.Year;

// Go back to the year in which the person was born in case of a leap year
if (birthdate.Date > today.AddYears(-age)) age--;
Posted by: Guest on July-01-2021
1

birth year calculator

// download moment.js

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

Code answers related to "age calculator from birthday"

C# Answers by Framework

Browse Popular Code Answers by Language