Carbon::setLocale() 不工作 Laravel 5.4

Carbon::setLocale() not working Laravel 5.4

我想用 Carbon 以这种格式打印当前日期:Miércoles 31 de octubre 2018 但我只得到 Wednesday 31 October 2018.

我已经用过:

Carbon::setLocale('es');
$fecha = Carbon::now()->format('l j F Y');

和:

Carbon::setLocale(LC_TIME, 'es');
$fecha = Carbon::now()->format('l j F Y');

config/app.php 中,我尝试使用:

Carbon\Carbon::setLocale('es');

我也试过 es_ES, es_MX, es_US, es_MX.utf8 但它一直返回日期英语。我正在研究 Linux,我已经添加了我需要的语言环境。

有人知道怎么解决吗?

尝试使用 PHP 函数 setlocale 同时检查您的主机是否允许并为您提供所需的语言环境。

setlocale(LC_TIME, 'es_ES');
 Carbon::setLocale('es');

这是Eimantas Gabrielius

给出的答案

可以看到

你好,用这个就行了

setlocale(LC_ALL, "es_ES", 'Spanish_Spain', 'Spanish');
echo iconv('ISO-8859-2', 'UTF-8', strftime("%A, %d de %B ", strtotime(Carbon::now())));