For a client, I had to find a way to get the percentage between today, x and an objective date, y. That will be useful for creating a reduced price, but the problem is I can’t do that with PHP or Javascript functions, only with one simple formula.
I have found this :
((x-y)/365)-(1*floor((x-y)/365))
x = The ordinal number of today (the 19th of October if the 291st day of the year)
y = The ordinal number of your objective day
Result : Decimal percentage of the ordinal number of days out of 365 with an objective day.
Now, I need feedback about it and see if there is a better way to get the same result or maybe if a mathematician sees this post he could teach me how to replace the “floor” function.