Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users

Dashboard
Notifications
Mark all as read
Challenges

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.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

1 comment thread

General comments (2 comments)

0 answers

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!