Age Calculator
Years, months and days, counted properly.
Years, months and days, counted properly.
How to use it
- Enter the date of birth. Written as YYYY-MM-DD.
- Leave the second field empty for today. Or set a date to work out an age at a point in the past or future.
- Read the breakdown. Years, months and days, plus the totals and the weekday of birth.
When you would use this
An age looks like a subtraction and is not one, because years and months are not fixed lengths. The quick approach divides the elapsed days by 365.25 and is wrong often enough to be noticed: the answer lands a day out depending on how many leap years fell in the gap, and an age calculator that is wrong on your actual birthday is obviously broken. This walks the calendar year by year and month by month, so a birthday lands exactly on the birthday. The part that catches implementations out is borrowing. When the day of the month has not been reached yet, the days borrowed have to come from the month before the target date rather than from the current one, and taking them from the wrong month puts the answer out by up to three days. There is a test for exactly that case. A 29 February birthday is handled as what it is: a date that exists only in leap years. No convention is invented to paper over it. A date of birth is one of the most commonly harvested pieces of personal information there is, and this one never leaves your browser.
Questions
- Why not just divide the days by 365.25?
- Because it is wrong often enough to notice. An average year length puts a birthday a day out depending on how many leap years fell in between, and an age calculator that is a day off on your birthday is obviously broken. This walks the calendar instead, so the count is exact.
- How is a 29 February birthday handled?
- As a day that only exists in leap years. Someone born on 29 February 2000 turns 26 on 29 February 2026, which does not exist, so on 28 February 2026 they are 25 years, 11 months and 30 days. That is the honest answer rather than a convention invented for the occasion.
- Is my date of birth sent anywhere?
- No. It never leaves the page. There is no server here, which is worth knowing given a date of birth is one of the more commonly harvested pieces of personal information there is.