Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

omrakhurs's avatar

How to add one day to the date retrieved using DB facade?

I want to add one day to my end date, which I retrieve as end. I have tried $holiday->end = $holiday-end->modify('+1 day');

Doesn't work.

Here is the code I'm trying to modify.

Route::get('/holidayapi', function () {
    $holidays = DB::table('holiday_requests')->select('id', 'name','startdate as start', 'enddate as end', 'status')->get();
    foreach($holidays as $holiday)
    {
        $holiday->title = $holiday->name . ' - ' .$holiday->status;
        $holiday->url = url('holidays/' . $holiday->id);


    }
    return $holidays;
});
0 likes
0 replies

Please or to participate in this conversation.