The 40-year-old is quite simple. But to get the exact decimal point, I'm not sure how you translate the rest of the age into a decimal number. You see that age is expressed in years, months, days, hours, seconds. And the calculation is not so simple. You have to deal with anniversary dates. For example, if someone was born on January 31, when they are 1 month old? The answer is March 1st. But in a few years it is in 28 days and a few years later in 29 days. Here is the javascript implementation I was trying to handle.
But I believe that a decimal number can express the number of days from the last birthday anniversary divided by the number of days until the next anniversary. And if you want to clarify, you can do it in seconds using the same principle.
But I think this is a bad idea of age. Usually we usually do not imagine such an age.
And make sure your dates are in the same time zone for your comparisons.
source share