PHP Difference in Days between two Dates - Calculate Days Between Dates in PHP
It is often handy to be able to calculate the difference between two dates or the number of days in between the two dates. The following PHP function does this in one simple line of code (the code can also be used in your PHP page rather than calling a function if speed is an issue).
It doesn't matter which date is earlier or later when you pass in the date parameters. The function uses the PHP ABS() absolute value to always return a postive number as the number of days between the two dates.
Keep in mind that the number of days between the two dates is NOT inclusive of both dates. So if you are looking for the number of days represented by all the dates between and including the dates entered, you will need to add one (1) to the result of this function.
For example, the difference (as returned by the above function) between 2013-12-02 and 2013-12-07 is 5. But the number of days or dates represented by the date range 2013-12-02 - 2013-12-07 is 6.
More: Useful PHP Scripts, Functions and Code Snippets