Age calculator: how the math handles months, leap years, and time zones
How an age calculator handles the edge cases people forget: leap years, day-of-month rollovers, time zones, and the difference between "completed years" and "calendar age". With three real examples and the gotchas in legal and medical contexts.
Calculating age sounds trivial: subtract birth date from today. The basic math is exactly that simple. The edge cases are where it gets interesting: leap year birthdays, month-day rollovers, time zone effects on newborns, and the legal vs medical conventions for what counts as "age". Most age calculators handle the basic case correctly and quietly mishandle some of the edge cases.
How the math works
The standard formula for age in completed years:
`age = (currentYear β birthYear)`, then subtract 1 if `(currentMonth, currentDay) < (birthMonth, birthDay)`.
Worked example: born March 15, 1990. Today is May 5, 2026. Year difference: 36. Has March 15 passed in 2026? Yes (it is May). So age is 36.
Counter-example: born May 20, 1990. Today is May 5, 2026. Year difference: 36. Has May 20 passed in 2026? No (it is May 5). So age is 35, not 36. The birthday this year happens later in the month.
For age in months or days, the same logic extends but with different units. Days are simplest: subtract the dates as integers (epoch math) and divide by the number of days in the requested unit.
Edge cases that matter
Leap year birthdays. Someone born February 29, 2000 turns 6 in 2024 (leap year, real Feb 29 exists), but how about non-leap years? Two conventions compete β civil law in most jurisdictions, including the United States and Brazil, treats March 1 as the legal birthday in non-leap years for purposes that need a single anchor day (passport renewals, driver license expiration). Some calendars and informal use treat February 28. The practical result: a leapling who turns 18 in a non-leap year becomes legally an adult on March 1, not February 28.
Time zones for newborns. A baby born at 11:50pm Eastern Time on March 31 was born March 31 by the local civil date. If the hospital records to a UTC-based system without adjustment, the timestamp is 3:50am UTC on April 1, and downstream systems may log the birth as April 1. The 1-day discrepancy propagates into birth certificates, insurance enrollment, and later age calculations. Hospital systems generally store the local civil date to avoid this, but data flowing across systems can re-acquire the bug.
Floor vs round. "29 years and 11 months" rounds to 30 in casual conversation but is 29 in legal terms. Age calculators almost universally floor to completed years, which matches how legal age thresholds work. Some health and fitness apps round up, over-stating age by up to 11 months.
When the difference matters
Legal thresholds. Driving age, drinking age, voting age, retirement age, statute of limitations on child claims β all use completed years. The day before a birthday and the day of a birthday are legally different states. Court cases involving juvenile vs adult treatment have hinged on whether an offense occurred at age 17 years 364 days or 18 years 0 days.
Insurance pricing. Life insurance and health insurance often price by age band, with cliffs at specific ages (50, 60, 65). A policy purchased at 49 years 11 months locks in a different premium than one purchased at 50 years 0 days β sometimes a difference of hundreds of dollars per year for the policy lifetime.
Retirement planning. Social Security claiming, Medicare enrollment, and 401(k) Required Minimum Distributions all key off specific ages with date precision. Claiming Social Security one month early vs at full retirement age locks in a permanently reduced benefit. The completed-year math is the legal anchor β but the calendar day of the application within that year affects the benefit by a fraction of a percent.
Try the calculator
Calculators mentioned in this post:
Age
Calculate exact age in years, months, days, hours. See your age on other planets, countdown to next birthday, and compare two people.
Pregnancy Due Date Calculator
Estimate your pregnancy due date with Naegele's Rule (LMP), known conception date, or first-trimester ultrasound. Cycle-length adjustment for cycles 21β35 days. Shows current gestational age, trimester, and key prenatal milestones.
Retirement Calculator 2026: 401(k), IRA, Roth + SECURE 2.0
Plan retirement with 2026 IRS limits ($24,500 401(k), $7,500 IRA, $11,250 super catch-up 60-63), employer match modeling with vesting, Roth vs Traditional bracket arbitrage, SECURE 2.0 Roth catch-up rule, and 30-year projection with inflation.
Frequently asked questions
How do I calculate age in completed years vs months?
Years uses the floor logic above (subtract years, adjust if birthday has not happened this year). Months extends the same idea: total elapsed months between two dates, floored. For "X years Y months", calculate years first, then count remaining months from the most recent birthday to today. The age calculator on the site does both automatically.
What age does a Feb 29 baby have on Feb 28 in a non-leap year?
Legally, in most US and Brazilian jurisdictions, the leapling does not yet have the new age until March 1 of a non-leap year. So on Feb 28 in a non-leap year, they still have last year's age. This affects driver license renewal dates, passport expirations, and any age-cliff legal threshold. Some informal usages count Feb 28, but the courts generally go with March 1.
Why do some calculators say I am one day older than others?
Time zone handling. If your birth was logged in UTC but you live in a different time zone, naively comparing today's local date with a UTC birth timestamp can shift by one day. This shows up most often for births close to midnight UTC. The fix is converting both dates to the same time zone before subtracting. The calculator on the site uses local time consistently to avoid this.
Does it matter if I count age in days, months, or years for legal purposes?
Mostly years for adult thresholds (drinking, voting, retirement). Days matter for newborns (insurance enrollment windows are typically 30 days from birth), and weeks matter for pregnancy timelines. The unit you use depends on the legal or medical context, not personal preference. Government forms specify; follow what they ask for.

