I managed to do this on excel by using the following (note that I use the dd/mm/yyyy date format:)
User inputs Date assigned to cell A101/01/2007
Calculation to find out current tax year =IF(MONTH(A1)<>4,YEAR(A1)-1,IF(DAY(A1)>=6,YEAR(A1),YEAR(A1)-1)) Result is the current tax year is year 2006
That Date’s Tax year begins = =DATE(A1,4,6) result of 06/04/2006
Day before the Tax year ends = =DATE(R54+1,4,5) result of 05/04/2007
Max number of days =ABS((R55-R56))+1 result = 365 (used to detect leap years)
Number of days passed in the tax year =ABS(R53-R55-R57) result = 95
Works out percentage of tax year left =(R58/R57)*100 result is 26.02739726
Now i need to do the same in PHP, and honestly have no idea where to start.
I would use PHP’s
DateTimeclass and theDateTime::diffmethod:The output of this code is:
http://codepad.viper-7.com/WNxRHS