How to get days difference between two dates in laravel?By Hardik Savani | January 29, 2016 | | 13039 Viewer | Category : Laravel
Whenever you need to get difference between two dates in date in laravel 5 then you can get easily using Carbon. Laravel by default provide Carbon class. Carbon class throught you can calculate difference between two dates in days.
In Following example you can see, we have a two dates, first $to variable and second one $from variable. Carbon class diffInDays function using you can get difference between two dates. I hope you will find your solution.
$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
- How to create blade view file using command line in Laravel?
- How to push item to 0 index or first of $scope object in AngularJS?
- Laravel 5 - Custom Helper Facade Class Example from scratch
- AngularJS - How to create read more/less toggle using Directive?
- How to create authentication(login and registration) in Laravel 5.2?
- PHP - autocomplete websites with domain and logo using clearbit API
- How to hide div after some time using AngularJS?
- How to create custom scrollbar using jquery mcustomscrollbar plugin ?