Carbon locale format and decline

Deadly 提交于 2019-12-11 01:12:32

问题


How I can set locale to carbon with format? I have date:

setlocale(LC_TIME, 'ru_RU.UTF-8');
Carbon::setLocale('ru');
$dt = Carbon::now()->formatLocalized('%d %M');

I Get Month with:

25 декабрь

How I can get locale with decline? Example:

25 декабря


回答1:


I've just tested it and this will return 25 декабря:

Carbon::now()->formatLocalized('%d %B');

In comments, you've said you have trouble with the date. Try this fix, from the Carbon Docs:

on Linux If you have trouble with translations, check locales installed in your system (local and production).

locale -a to list locales enabled.

sudo locale-gen fr_FR.UTF-8 to install a new locale.

sudo dpkg-reconfigure locales to publish all locale enabled.

And reboot your system.

http://carbon.nesbot.com/docs/



来源:https://stackoverflow.com/questions/47972009/carbon-locale-format-and-decline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!