Laravel Carbon Add Days to Date Example

Laravel Carbon Add Days to Date Example

Hello friends, Today i will show Laravel Carbon Add Days to Date Example. Carbon provides addDay() and addDays() method to add days on carbon date object. We will show example of add days carbon laravel.

We will see laravel carbon add days. In this post we will show how to add days in date in laravel 8. so let’s following examples to adding day and days from date.

Carbon Add Day to Date in Laravel

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Carbon\Carbon;
  
class SignaturePadController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function index()
    {
        $currentDateTime = Carbon::now();
        $newDateTime = Carbon::now()->addDay();
             
        print_r($currentDateTime);
        print_r($newDateTime);
    }
}

Carbon Add Days to Date in Laravel

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Carbon\Carbon;
  
class SignaturePadController extends Controller
{
    /**
     * Write code on Method
     *
     * @return response()
     */
    public function index()
    {
        $currentDateTime = Carbon::now();
        $newDateTime = Carbon::now()->addDays(5);
             
        print_r($currentDateTime);
        print_r($newDateTime);
    }
}

I hope you understand of Laravel Carbon Add Days to Date and it can help you…

Read Also :  How to get Random Value from Array in laravel