Laravel 6 - Get difference between two dates in days using carbon

Laravel 6 , Laravel

Nicesnippets

17211

04-10-2019


hi guys,

In this example, I will help you to How to get difference between two dates in days using carbon in laravel 6. you need to get difference between two dates in count to days using carbon in laravel 6.you can simply use to diffInDays() method in laravel 6.

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...


Recommended Posts