Configure Laravel to use Immutable dates by default

September 29th, 2023

By default, Laravel uses Carbon for dates, but the object returned by the \Illuminate\Support\Facades\Date helper is mutable.

To configure Laravel to use CarbonImmutable instead, call this method in your AppServiceProvider's boot() method:

use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Date;

class AppServiceProvider extends ServiceProvider
    public function boot()

Just make sure to use Laravel's Date facade instead of Carbon directly in your application code.