I'm trying to localize Carbon dates in a view in different languages with no success so far.
I retrieve dates from a Model and send them to a view:
Route::get('/tables/setup', function(){
$now= Date::now('Europe/Paris');
$active_tasks = GanttTask::whereDate('start_date', '<', $now)
->whereDate('end_date', '>', $now)
->get();
return view('my_view', compact('active_tasks'));
});
and can easily display them in 'my_view':
@foreach($active_tasks as $active_task)
{{$active_task->start_date->format('l j F Y H:i:s')}} //Friday 26 January 2018 09:19:54
@endforeach
But I can not manage to render them in the desired language.
I tried adding Carbon::setLocale('it');
in the route or in the view with no effect.
EDIT:
slight error in my blade call {{$active_task->start_date->format('l j F Y H:i:s')}}
instead of {{$active_task->format('l j F Y H:i:s')}}