Snippets
How to get difference between two dates in laravel?
Laravel use Carbon out of the box. If you are thinking about how to get the difference between two dates in laravel, here is the tip for you.
$today = Carbon\Carbon::now();
$threeMonthsFromNow = Carbon\Carbon::now()->addMonths(3);
$totalDays = $today->diffInDays($threeMonthsFromNow);
Here, I just calculate today
and 3 months later from today. The carbon will add 3 months automatically with today's date by line Carbon\Carbon::now()->addMonths(3);
.
Hope it will work for you.