Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marcoplus's avatar

Laravel Translation months

Why doesn't the translation of the name of the month work? I have this code but whatever I do it doesn't change the name, it always remains in English. I'm using Laravel 10 and PHP 8.2.12

<td>
        @php
                  setlocale(LC_TIME, 'it');
                  $date = strtotime($val['date_logs']);
                  $dat = date('F', $date);
         @endphp
         {{ $dat }}
</td>

Result : January

0 likes
2 replies
tisuchi's avatar
tisuchi
Best Answer
Level 70

@marcoplus Make sure that you set the configured language in the config file properly. Setting timezone globally is preferable.

However, alternatively, this might work.

@php
    setlocale(LC_TIME, 'it_IT');
    Carbon\Carbon::setLocale('it');
    $dat = Carbon\Carbon::parse($val['date_logs'])->translatedFormat('F');
@endphp
{{ $dat }}
3 likes
marcoplus's avatar

@tisuchi Thanks for the reply, yes I followed the steps to do it in config app

'timezone' => 'Europe/Rome',
  'local' => 'it',
   'fallback_locale' => 'it',
   'faker_locale' => 'it_IT',

I also added Laravel Lang

2 likes

Please or to participate in this conversation.