The dating code
The correct alghoritm is:if (year is not divisible by 4) then (it is a common year)else if (year is not divisible by 100) then (it is a leap year)else if (year is not divisible by 400) then (it is a common year)else (it is a leap year)So the code should look like this:if($year%4 == 0 && $year0 !
= 0) elseif([email protected] == 0) else While this will work for the majority of years it will not work on years that are multiples of 100 but not multiples of 400 i.e.(2100).
Monday-Friday, excluding holidays) between any two given dates.
I couldn't find a simple way to do that in PHP, so I threw this together.
It replicates the functionality of Open Office's NETWORKDAYS function - you give it a start date, an end date, and an array of any holidays you want skipped, and it'll tell you the number of business days (inclusive of the start and end days! I've tested it pretty strenuously but date arithmetic is complicated and there's always the possibility I missed something, so please feel free to check my math.
The function could certainly be made much more powerful, to allow you to set different days to be ignored (e.g.
"skip all Fridays and Saturdays but include Sundays") or to set up dates that should always be skipped (e.g.