Comments on Calculate a person's age
Post
Calculate a person's age
+4
−0
Challenge
Given a date with day, month and year, calculate how old a person born on that day would be today.
Input can be in any reasonable format(params, array, date object).
Input will never be invalid.
Output must consist of years, months and days in any order you specify.
Date and Time libraries are allowed.
Testcases
These are with respect to 2nd January 2021. It will change depend on when you answer. Use this site to verify your answers.
1st September 2003 - 17 years 4 months 1 day
6th December 2016 - 4 years 0 months 27 days
12th April 1985 - 35 years 1 month 28 days
Here are the testcases in a more suitable format.
1 comment thread