Laravel Get Difference Between Two Dates in Days Example
hi guys,
In this example, I will help you to How to get difference between two dates in days using carbon in laravel. you need to get difference between two dates in count to days using carbon in laravel.you can simply use to diffInDays() method in laravel.
In Following example you can see, we have a two dates, first $start_date variable and second one $end_date variable. Carbon class diffInDays function using you can get difference between two dates. I hope you will find your solution.
Example 1 :
/**
* Show the application dashboard.
*
* @return \Illuminate\Contracts\Support\Renderable
*/
public function index(Request $request)
{
$start_date = \Carbon\Carbon::createFromFormat('d-m-Y', '1-5-2015');
$end_date = \Carbon\Carbon::createFromFormat('d-m-Y', '10-5-2015');
$different_days = $start_date->diffInDays($end_date);
dd($different_days);
}
It will help you...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial