How to set language for Carbon?

前端 未结 2 1838
甜味超标
甜味超标 2021-01-18 06:55

So i want to set language for Carbon, but i always get same result.

  Carbon::setLocale(\'es\');
$archive_current_year = Articles::whereBetween(\'created_at\         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-18 07:35

    Carbon is actually using the php setlocale();. The Carbon::setLocale('es') method is only for localized Carbon methods like ->diffForHumans() method.

    As explained here, notice that the php setlocale() reference to the locale stored on your OS. To choose one of the installed one, type locale -a on your console. Secondly, you will have to use ->formatLocalized() method instead of ->format() in order to use the format on the desired locale which can be found at the following link.

    http://php.net/manual/en/function.strftime.php

提交回复
热议问题