Laravel

Laravel-find days between two dates in laravel

In this blog, we will learn about how to find days between two dates in laravel, This tutorial will give you a simple example of getting days difference in laravel. if you want to see an example of how to get days difference in laravel then you are in the right place. Follow the below tutorial step of laravel 8 gets last week’s records from the database.

If you want to see what all carbon does then you can check this link.

By using the below code you can get the days difference between two dates in laravel.

$to = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', '2015-5-5 3:30:34');
$from = \Carbon\Carbon::createFromFormat('Y-m-d H:s:i', '2015-5-6 9:30:34');

$diff_in_days = $to->diffInDays($from);

print_r($diff_in_days); 

// Output: 1

I hope now, you understood how to get the days difference between the two dates, feel free to rate my article.

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button