Age Calculator โ Exact Age in Years, Months & Days
Enter a date of birth to calculate exact age in years, months, and days, plus total weeks, days, and hours, and the days remaining until the next birthday.
Age Calculator
You were born on a Monday
Next birthday: 144 days away (turning 37)
Your age in other units
Life progress
Your age against an illustrative 80-year reference span.
Documentation
What is an age calculator?
An age calculator finds the exact time between two dates: a date of birth and a target date, usually today. It reports the result as years, months, and days, and also as a running total in weeks, days, hours, minutes, and seconds. Age can also be calculated for a past or future date, which shows how old a person was, or will be, on that day.
How to calculate age
Age is the gap between two calendar dates. There are two correct ways to describe that gap, and both are useful for different purposes.
Calendar age (years, months, days)
This is the everyday way people state their age, such as "33 years, 4 months, and 5 days old." It is found in three steps:
- Count the whole years that have passed since the birth date.
- From the most recent birthday, count the whole months that have passed.
- From there, count the remaining days.
Step 3 gets tricky near the end of a month, because months do not all have the same number of days. Someone born on 31 January, whose age is measured on 1 March, is 1 month and 1 day old. One month after 31 January is 28 February (or 29 February in a leap year), since there is no 31 February. 1 March is one day after that. This method, sometimes called the relativedelta rule after the Python library that popularized it, clamps the anniversary date to the last day of the shorter month so the day count never goes negative.
Total elapsed time (days, hours, seconds)
For a precise count of time lived, both dates are converted to a single point in time and the difference is taken in whole days:
days = floor((target date โ birth date) รท 86,400,000 milliseconds)
Both dates are set to midnight UTC (Coordinated Universal Time) before the subtraction. This stops daylight-saving time changes from adding or removing an hour and skewing the day count. From the day total, weeks are days divided by 7, rounded down. Hours, minutes, and seconds are the day count multiplied by 24, 1,440, and 86,400.
Dividing total days by 365 or 365.25 gives an approximate age in years, but it does not know which years in that span were leap years. Calendar counting, described above, is exact. Use calendar age to answer "how old am I." Use total days or weeks for tasks that need precise elapsed time, such as timing medication doses or counting down to a milestone.
Worked example
A person born on 1 January 2000, with age measured on 1 January 2020:
| Measure | Value |
|---|---|
| Calendar age | 20 years, 0 months, 0 days |
| Total days | 7,305 |
| Total weeks | 1,043 |
| Day of the week born | Saturday |
The total of 7,305 days equals 20 ร 365 plus 5 leap days, for the leap years 2000, 2004, 2008, 2012, and 2016. Each of those years added a 29 February that falls inside the 20-year span. That is why the day count is higher than a simple 20 ร 365, and why calculating it by hand is easy to get wrong by a few days.
Age calculation formula in code
The calendar-age method above can be implemented in most programming languages. Using a built-in date library is safer than writing the leap-year and month-length rules by hand.
1from dateutil.relativedelta import relativedelta
2from datetime import date
3
4birth, target = date(2000, 1, 1), date(2020, 1, 1)
5
6age = relativedelta(target, birth) # calendar age
7print(f"{age.years}y {age.months}m {age.days}d")
8
9total_days = (target - birth).days # total elapsed days
10print(total_days) # 7305
111function calendarAge(birth, target) {
2 let months = (target.getUTCFullYear() - birth.getUTCFullYear()) * 12
3 + (target.getUTCMonth() - birth.getUTCMonth());
4 const anchor = new Date(Date.UTC(birth.getUTCFullYear(), birth.getUTCMonth() + months, birth.getUTCDate()));
5 if (anchor > target) months--;
6 return { years: Math.floor(months / 12), months: months % 12 };
7}
8
9const totalDays = Math.floor((target - birth) / 86400000); // 7305
101' Whole days between two dates (A1 = birth, B1 = target):
2=B1-A1
3
4' Calendar age in complete years / months / leftover days:
5=DATEDIF(A1, B1, "y") & " years, " & DATEDIF(A1, B1, "ym") & " months, " & DATEDIF(A1, B1, "md") & " days"
6Frequently asked questions
How do I find my exact age? Enter a date of birth and leave the target date on today. The result gives age in years, months, and days, along with the same age in total days, weeks, hours, and seconds.
Why do two age calculators give different answers? The difference is usually in how the leftover days near a month boundary are counted. A calculator that clamps to the shorter month at month-end, as described above, can differ by a day or two from one that simply divides elapsed time by 30.
Does the calculation account for leap years? Yes. The total day count includes every 29 February that falls between the two dates, and a birth date of 29 February is measured correctly against 28 February or 1 March in years that are not leap years.
Can age be calculated for a date in the past or future? Yes. Setting the target date to a future date shows how old someone will be on that day. Setting it to a past date shows how old they were.
Do time zones affect the result? No. Both dates are converted to UTC midnight before the day count is taken, so the total stays the same regardless of the user's location or daylight-saving changes.
Why does the day count differ from dividing days by 365.25? 365.25 is only an average year length; it does not track which specific years in the span are 366-day leap years. Counting whole days between two real calendar dates is exact.
Sources
- Python
dateutilโrelativedelta, the calendar-age month/day rule described above. - Java Platform โ
Period.betweenandChronoUnit.DAYS. - Microsoft Excel โ
DATEDIFfunction. - MDN Web Docs โ
Date. - Dershowitz, N., & Reingold, E. M. Calendrical Calculations: The Ultimate Edition. Cambridge University Press, 2018.