Age Calculator
Compute calendar-aware age and optional total months, weeks, and days.
Your calculation is performed locally in your browser.
Results are estimates for informational purposes and should not be treated as financial, tax, or investment advice.
Select dates and click Calculate.
Use in code
Calendar-aware age requires month/day adjustments rather than simple millisecond division.
Compute calendar age
TypeScriptPrimary API
subtract year, then borrow month/day when needed
Adjusts years and months based on calendar boundaries.
Built-in API
function ageYearsMonthsDays(dob: Date, asOf: Date) {
let years = asOf.getUTCFullYear() - dob.getUTCFullYear();
let months = asOf.getUTCMonth() - dob.getUTCMonth();
let days = asOf.getUTCDate() - dob.getUTCDate();
if (days < 0) {
months -= 1;
}
if (months < 0) {
years -= 1;
months += 12;
}
return { years, months, days };
}How this calculator works
- Enter date of birth.
- Choose an as-of date (defaults to today).
- Read years, months, days, and optional totals.
Use cases
- Calculate age for forms and planning.
- Compare exact calendar age with total-day approximations.
Limitations and assumptions
- Requires valid dates and cannot calculate from future birth dates.
- Time-of-day and timezone offsets are intentionally ignored for date-only consistency.
FAQ
Why not divide milliseconds by 365?
That approximation ignores leap years and variable month lengths, so it can be wrong near birthdays.