V
V
viktorross2019-02-26 12:33:00
Laravel
viktorross, 2019-02-26 12:33:00

How to do localize date in laravel?

Hello
Can you please tell me how to localize the date in the laravel script?
I have never used it, so I don’t understand.
I found several modules, but it’s not clear where and what to install.
Maybe someone knows in detail

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2019-02-26
@ellenripley4

Try this:
French locale example:

$date = Carbon::now()->locale('fr_FR');

echo $date->locale();            // fr_FR
echo "\n";
echo $date->diffForHumans();     // il y a 1 seconde
echo "\n";
echo $date->monthName;           // février
echo "\n";
echo $date->isoFormat('LLLL');   // lundi 25 février 2019 22:28

Display a list of available locales (to find out the exact spelling of the Russian locale):
Link to Documentation

R
Roman, 2019-02-26
@procode

Usually they use Carbon, but I don’t need it - I didn’t use it myself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question