Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Carbon locale not respected?

In my Laravel 6 app, I have Carbon::now()->locale() returning it as it should be.

As confirmation that the locale is loaded, Carbon::now()->monthName correctly outputs febbraio.

BUT Carbon::now()->format('F') and Carbon::now()->formatLocalized('%B') both return the english version February.

Why does the first function output the correct localized month while the others do not?

like image 807
NevNein Avatar asked Oct 14 '25 08:10

NevNein


1 Answers

Apparently, formatLocalized() is somehow deprecated or not working as intended.

From the Carbon docs:

You also may know formatLocalized() method from Carbon 1. This method still works > the same in Carbon 2 but you should better use isoFormat() instead.

Carbon::now()->isoFormat('MMMM') is working as intended and correctly returns febbraio.

like image 172
NevNein Avatar answered Oct 17 '25 02:10

NevNein



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!