Calculate age in year, month, days with Java Script - three different fields
- April 9, 2021
- 1 reply
- 2046 views
Hello everyone, I have a question about automatic age calculation with Java Script. I've already searched the entire forum, but unfortunately nothing really fits my case.
Enclosed you will find a picture with a table. Since it is in German, here the terms line by line from left to right: year, month, day. And on the left (from top to bottom) test date, date of birth, age. I would like the client to first enter the test date in the first line, spread over three fields, e.g. 2021 - 04 - 09 and below the date of birth, e.g. 1990 - 11 - 17.
How do I manage that the age is automatically calculated in years, months and days, but distributed over the three fields? Leap years must also be taken into account, I guess? A simple subtraction doesn't work either, of course, because both, the value of the month and the day, could be higher and somehow the total number of months and days must also play a role, right?
As you can see, I am a Java Script beginner and would be grateful for any help!
