This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

calculate diferent between years, month, days
#1
Hi,

I try to make a script to calculate years, month days between 2 dates.
I will check like 2 September 2006 and today (16 April 2022)

output must be: 15 years, 7 months, 14 days

i try to make this, but it is really hard for,
i can calculate years 2022 - 2006 - 1 = 15

but if i m with months like this, April = 4, September is 9
4 - 9 = crashing for me
Because it is negative, and it has to take an extra year of the previous calculation.

And the same with days.

Did someone already think how to do this, or is there already an example for doing this?

Before I was thinking to do it with seconds, but that's even harder I think, because there are months like 28 / 29(once a 4 years) / 30 or 31
Reply


Messages In This Thread
calculate diferent between years, month, days - by Dré - 16.04.2022, 13:28

Forum Jump: