How can I change what days Carbon considers the weekend?

Viewed 2036

I want to change weekendDays to only include Sunday in my Carbon Instance. How can I do that?

1 Answers

Run:

Carbon::setWeekendDays([Carbon::SUNDAY]);

In your App\Providers\AppServiceProvider in the boot function.

Edit:

setWeekendDays is deprecated. Use macro instead.

Carbon::macro('isDayOff', function ($date) {
   return $date->isSunday();
});

$isDayOff = $carbon_inst->isDayOff(): bool;
Related