CalculatorsLesson 168Free preview
Age Calculator
This lesson is part of Web Developer Tools · All levels
Summary
Age calculator determines age based on birth and reference dates, usually today. The age in the year is calculated by subtracting the previous year to adjust whether the birthday in the previous year has passed. The tool can also display age in the following month, week, day, and birthday.
Key points
- Age = reference year - year of birth, minus 1 if the birthday is not yet past
- Birthdays of February 29 are handled with special rules
- Age in a day is different from age in a year times 365
- The reference date can be changed for simulation
- Use a consistent time zone
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.