Reputation: 495
Is there any suitable method in the carbon library which returns the number of days in a date range? I have gone through similar question but they are about total number days between two dates, and not the number of days in a date range.
This is what I'm doing right now.
carbon::create($till_date)->diffInDays(carbon::parse($from_date)->subDay())
Upvotes: 2
Views: 1373
Reputation: 5056
Simply count the diff on days begin:
Carbon::create($till_date)->startOfDay()->diffInDays(carbon::parse($from_date)->startOfDay())
And just do +1
if you want to include the last day in the count.
Upvotes: 2