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
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