问题
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