Skip to content
Toolbrik
Back to blog

How an exact age in years, months and days is actually calculated

September 22, 2026 · Related tool: Exact Age Calculator

"Subtract the birth year from the current year" works as a rough estimate, but it's wrong two days out of three: if your birthday hasn't happened yet this year, that subtraction gives you an age that's one year too high.

The correct calculation

Calculating an exact age in years, months and days means comparing all three parts of the date, not just the year:

  1. Calculate the difference in years.
  2. If the current month and day are earlier than the birth month and day, subtract one year from that result (the birthday "hasn't arrived yet").
  3. Calculate the remaining months and days, borrowing from the previous month/year when the current day is smaller than the birth day — the same mechanism as borrowing in column subtraction.

The exact age calculator handles this adjustment automatically and also gives you the total in days, weeks and hours — useful for paperwork that asks for age in units other than "years."

The February 29 case

Anyone born in a leap year has a genuine calendar problem: their birthday only exists every 4 years. The most common convention (and the one most legal and administrative systems use) is to treat February 28 or March 1 as the "effective" birthday in non-leap years, depending on the jurisdiction. If your application calculates legal age or deadlines from a February 29 birth date, it's worth deciding explicitly which convention you use — rather than leaving it implicit and discovering the bug once every four years.

Time zones: why "today" isn't the same everywhere

If your app calculates age on the server using the server's date, and the user is in a different time zone, there can be up to a day's discrepancy near midnight. For age calculations that matter legally (age verification, for instance), you should use the user's local date, not the server's — or at least be aware of where it can go wrong. If you need to convert between time zones to debug this kind of case, the timezone converter helps visualize the gap.

Age in months for babies

One special case: a baby's age is almost always expressed in months, not years ("she's 7 months old"), and there the same years/months/days algorithm applies but shows only the months-and-days portion — without rounding up to "almost 1 year," which is where most of the confusion happens on vaccination records and pediatric checkups.