RobDeFlop
RobDeFlop

Reputation: 59

Carbon for Laravel is not displaying the day name

glad to be here

I am currently taking a deeper look into Laravel and found a class (Carbon - Time formatting) that is interesting for me. But now I've got the problem, that the German day name is not displayed. If I switch the locale to English its gonna be displayed.

In my index.blade.php

{{dd(Carbon\Carbon::tomorrow()->formatLocalized('%A %d %B %Y'))}}

and it returns: b"Donnerstag 29 März 2018"

and if I remove the dd() it won't be displayed anymore. Maybe someone knows a solution to solve this problem.

Best regards, RobDeFlop

Upvotes: 2

Views: 1234

Answers (2)

Suniti Yadav
Suniti Yadav

Reputation: 403

Please refer this link:

https://carbon.nesbot.com/docs/

Try this:

setlocale(LC_TIME, 'German');
echo $dt->formatLocalized('%A %d %B %Y');      // Mittwoch 21 Mai 1975
setlocale(LC_TIME, 'English');
echo $dt->formatLocalized('%A %d %B %Y');      // Wednesday 21 May 1975
setlocale(LC_TIME, ''); // reset locale

Upvotes: 1

Jonas Staudenmeir
Jonas Staudenmeir

Reputation: 25906

It's a Windows issue. Add this to your code:

\Carbon\Carbon::setUtf8(true);

Then {{ Carbon\Carbon::tomorrow()->formatLocalized('%A %d %B %Y') }} works.
You shouldn't use {!! ... !!} for that.

Upvotes: 2

Related Questions