Skip to content
Advertisement

How can I change what days Carbon considers the weekend? [closed]

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

Advertisement

Answer

Run:

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

In your AppProvidersAppServiceProvider in the boot function.

Edit:

setWeekendDays is deprecated. Use macro instead.

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

$isDayOff = $carbon_inst->isDayOff(): bool;
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement