Skip to content
πŸ› οΈToolsShed

Age Calculator

Calculate exact age in years, months, and days from a birth date.

About this tool

An age calculator is a simple tool that computes your exact age down to the day by comparing your birth date to today's date. Knowing your precise age in years, months, and days matters for official documents, health records, eligibility verification, and personal milestones. This calculator eliminates manual math and the risk of error, giving you an instant, accurate answer.

To use it, enter your birth date in the provided field and click the calculate button. The tool instantly displays your age broken down into years, months, and days, plus your exact age in weeks, days, or hours if you want deeper detail. Common uses include checking eligibility for age-restricted services, verifying information for bureaucratic forms, tracking how much time has passed since a significant life event, and satisfying curiosity about your exact age.

Frequently Asked Questions

Code Implementation

from datetime import date

def calculate_age(birthdate: date, today: date = None) -> dict:
    """Calculate age in years, months, and days."""
    if today is None:
        today = date.today()
    years = today.year - birthdate.year
    months = today.month - birthdate.month
    days = today.day - birthdate.day
    if days < 0:
        months -= 1
        # Days in the previous month
        prev_month = today.replace(day=1)
        import calendar
        days_in_prev = calendar.monthrange(prev_month.year, prev_month.month - 1 or 12)[1]
        days += days_in_prev
    if months < 0:
        years -= 1
        months += 12
    return {"years": years, "months": months, "days": days}

# Example
birth = date(1990, 6, 15)
age = calculate_age(birth)
print(f"Age: {age['years']} years, {age['months']} months, {age['days']} days")

total_days = (date.today() - birth).days
print(f"Total days lived: {total_days}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.