CalculatorsLesson 167Free preview
Date & Age Calculator
This lesson is part of Web Developer Tools · All levels
Summary
Date & Age Calculator calculates the difference between two dates in a year, month, and day, or determines the age from the date of birth. The calculations were based on the calendar, not simply dividing the number of days by 365, because the lengths of the moons and the year of the equinoxes differed. The results usually separate the components of the year, month, and day so that it is easy to read.
Key points
- Calculations are based on a calendar, not an average number of days.
- Components of the result include years, months, and days
- The year of the equinox adds February 29
- The order of dates affects the result, use absolute values for the difference
- For consistency, use a date without clock or UTC time zone
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.