Answer the question
In order to leave comments, you need to log in
How to localize date in Laravel 4?
According to the documentation, Laravel uses Carbon when working with dates, which has a formatLocalized method . Example from documentation:
setlocale(LC_TIME, 'German');
echo $dt->formatLocalized('%A %d %B %Y'); // Donnerstag 25 Dezember 1975
setlocale(LC_TIME, 'ru_RU'); // это происходит в routes.php
// а это в шаблоне
// цикл и разметку я опустил, дело происходит в foreach
{{{$value->created_at->formatLocalized("%A")}}} // ожидаю увидеть "Четверг", но выводится пустая строка
<?php
setlocale(LC_TIME, 'ru_RU');
echo strftime("%A"); // корректно выводит "Четверг"
?>
Answer the question
In order to leave comments, you need to log in
I can only assume that you need to change to the desired locale in the config /app/config/app.php 'locale' => 'en',
Here is a great date localization solution for Laravel https://github.com/LaravelRUS/localized-carbon
Supports multiple languages
English (en)
Russian (ru)
Ukrainian (uk)
Dutch (nl)
Spanish (es)
Portuguese (pt)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question