Extend date to 3 more hours where post = today's post
I know the title is a bit confusing. I myself am trying to make sense of it. Basically I am using Carbon to get the posts for today and this is how it looks like.
So with this, I am getting the reservations made for today (if any). Now that means that the reservations will not be visible after 12:00 AM/24:00. But I want it to be visible till 03:00 AM. So basically its tomorrow and no longer today. How can I achieve this.
It's better to do a whereBetween here on the date column. So something like this
$now = Carbon::now();
$start = Carbon::now()->startOfDay();
$end = Carbon::now()->endOfDay();
// We need this to make sure you see the results from the day before until 3AM
// After 3AM it will show the rest of the day.
if ($now->hour < 3) {
$start->subDay();
$end->subDay();
}
$reservations = Reservation::whereBetween('reservation_made_on', [$start, $end])->get();
Note that you can also update $start and $end to be a specific date range. Now it's always from 00:00 to 24:00 but I can image you might want it to be 03:00 till 03:00 the next day
So now it will show all the reservations which were made for today and keep them till tomorrow 3AM (bacuse of 3 hours added). But my question is this. Will it collapse with the todays data? I mean if it is 3AM, it will show tomorrows data and todays data right? So is it better to do