How to find number of days between two dates using PHP?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Using this simple function. Declare function
and call this function like this where you want
If you're using
PHP 5.3 >
, this is by far the most accurate way of calculating the difference:Well, the selected answer is not the most correct one because it will fail outside UTC. Depending on the timezone (list) there could be time adjustments creating days "without" 24 hours, and this will make the calculation (60*60*24) fail.
Here it is an example of it:
So the correct solution will be using DateTime