Answer the question
In order to leave comments, you need to log in
Why does the Date library (an extension for Carbon) not work on hosting, but works on local (yes, again about setlocale() and cases of the month)?
Of good!
I've been struggling with this issue for several days now. Input: Laravel 5.3, Carbon and jenssegers/date installed . I want to display the date of writing a blog post in the format ДД месяц ГГГГ
(month with a small letter and in the genitive case, that is 10 ноября 2016
).
I do this in the controller:
use Jenssegers\Date\Date;
// ...
setlocale(LC_TIME, 'ru_RU.UTF-8'); // Пробовал любые варианты написания 'ru_RU'
Date::setLocale(config('app.locale')); // 'locale' => 'ru'
$article = Article::where('id', '=', $id)
->firstOrFail();
$created_at = Date::parse($article->created_at)
->formatLocalized('%e %B %Y');
return view('pages.article', compact(
'article', 'created_at',
));
// ...
<p>Пост написан {{ $created_at }}.</p>
php artisan serve
10 ноября 2016
10 Ноябрь 2016
Answer the question
In order to leave comments, you need to log in
The matter turned out to be in the hosting settings (modules), which "within the framework of this virtual hosting cannot be changed." Therefore, in this problem, only moment.js or switching to VDS will help.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question