3 years ago

Laravel $dates, from Carbon, does not use app language

Posted 3 years ago by canfiax

When I change my application locale to danish, it does not change Carbon language.

If I do:

app()->getLocale(); // da (danish)
$mymodel->created_at->getLocale(); // en

How can I get Laravel to set its Carbon instance to the current locale? I have tried setting Carbon::setLocale('da') in a middleware, and that works if I do Carbon\Carbon::now()->getLocale(), but not for eloquent models.

Please sign in or create an account to participate in this conversation.