Manipulation of dates in laravel are printed in English using Carbon formatLocalized

1

I am showing the dates in my view show using Carbon from the controller, but when displaying in Spanish the dates are not shown with "Wednesday" or "Saturday.

Controller

$tiempo = new Carbon($orden->Fecha_de_Inicio);
    setlocale(LC_TIME, 'es');
    $orden->Fecha_de_Inicio = $tiempo->formatLocalized('%a %d de %B de %Y - %H:%M%p');

View

 <div class="col-lg-4 col-md-12 col-sm-12 col-xs-12">
            <div class="box box-solid box-info" data-widget="box-widget">
                <div class="box-header centrar-texto">
                    Inicio: {{$orden->Fecha_de_Inicio}}
                    <h3 class="box-title">
                    </h3>
                </div>
            </div>
        </div>

I have tried changing the setlocale (LC_TIME, 'is'); but the dates are still not shown in the format I need.

My project is in local host, at the time of placing the project in the hosting all dates are shown in English even using the setlocale (LC_TIME, 'is');

    
asked by Santiago Ona 13.07.2017 в 03:52
source

1 answer

1

is badly organized

//primero inicializa el LC_Time
setlocale(LC_TIME, 'es');
$tiempo = new Carbon($orden->Fecha_de_Inicio);
$orden->Fecha_de_Inicio = $tiempo->formatLocalized('%a %d de %B de %Y - %H:%M%p');

can also do with the static function:

Carbon::setLocale('es');
echo Carbon::now()->addYear()->diffForHumans();

also the error can come from the system:

The problem come from your system. for Linux you can: locale -a to activate the list of locales.

then you can sudo locale-gen id_ID.UTF-8 to install and then sudo dpkg-reconfigure locales to publish them.

reboots the system. and let's see what happens.

Documentation: link

    
answered by 13.07.2017 в 05:18