Good Morning to all,
Finding the number of days between two dates is very useful and very important in day to day activity. Its very used in developers for like leave request because we select the date range and stored to database. From the selected data: from date and to date we find the number of days between these selected dates, and stored to database.
There are different methods are available to find the date diffrence between two date. In php date_diff() functions are available to find the date difference.
Method 1: PHP date_diff() Function
Calculate the date diffrence between two date using date_diff() in php. Its very simple method to solve this situations. The date_diff() function returns the difference between two Date. It is the easiest way to calculate the date difference in PHP.This function available from PHP version 5.3.0.
The date_diff() format is: date_diff($date1, $date2);
Example
format("%R%a days"); ?>
From the above code we get +5. Store the two date in php variable like $date1 and $date2. And use date_diff() to calculate the difference.
Method 2:
From the above code we get the output 6.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.