V
V
Vic Shostak2016-11-10 21:19:19
Laravel
Vic Shostak, 2016-11-10 21:19:19

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',
));

// ...

I display in the template: On the localhost with (OS X 10.11.6) - everything is displayed as it should - . Moreover, what with the jenssegers/date library , what without it (just Carbon). OK. I upload all this to the hosting (Timeweb) and see the following output of the date: (month with a capital letter and in the nominative case). Because of what it can be? Is this to the hoster or am I doing something wrong in Laravel?
<p>Пост написан {{ $created_at }}.</p>
php artisan serve10 ноября 2016
10 Ноябрь 2016

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vic Shostak, 2016-11-14
@vikkyshostak

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 question

Ask a Question

731 491 924 answers to any question