Try change locale using
// Set carbon
\Carbon\Carbon::setLocale($locale);
But is strange since that should be done by Laravel as I know
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
The dates in the comment table follow the laravel's own timestamps pattern. That is, both created_at and updated_at are stored as follows: 2020-09-05 20:04:08
However, the site is multi-language, and I need to format the date according to the language directly on the controller. Look:
Controller Comments:
public function relatoUser(Request $request) {
$comments = Comment::where('relato_id', $request->id)->paginate(10);
return view('userRelato', compact('comments'));
}
My blade:
@foreach($comments as $c)
<card-comment
created="{{ $comments->created_at->format('d/m/Y') }}">
</card-comment>
@endforeach
But in this way, in all languages the graduate will appear in the Brazilian standard. Is there a way for me to determine this format still in the controller after checking the language that makes the request?
So I put just that {{ $comments->created_at }} and the date appears according to the user's language.
Please or to participate in this conversation.