Replies: 1 comment
-
Hello.
For the record, in Carbon v3, when creating a And currently you can already create explictly $period = CarbonPeriodImmutable::create('Today', '6 hours', 'Tomorrow');
var_dump(array_map(get_class(...), $period->toArray())); All the items here in the array are You can get the same result starting from a $period = CarbonPeriod::create('Today', '6 hours', 'Tomorrow')->setDateClass(CarbonImmutable::class);
var_dump(array_map(get_class(...), $period->toArray())); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've posted this 3 years ago in ideas (laravel/ideas#1546):
As I'd like to work with immutable dates in my project, I've added
\Illuminate\Support\Facades\Date::use(\Carbon\CarbonImmutable::class);
to my AppServiceProvider. In that way, Laravel does always return an instance ofCarbonImmutable
instead ofCarbon
(i.e. when usingnow()
).But of course this doesn't change the items of
\Carbon\CarbonPeriod
toCarbonImmutable
.So, as we have a
Date
facade, what about aDatePeriod
facade, that respects the setting ofDate::use()
?Beta Was this translation helpful? Give feedback.
All reactions