@rsdev000 This will work for you, once you've added the locale:
setlocale(LC_TIME, 'es_ES.utf8');
>>> Carbon\Carbon::now()->formatLocalized('%A %d %B %Y');
=> "domingo 08 febrero 2015"
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all
I have a model with a timestamp field named start_at. The date was displayed as yyyy-mm-dd hh:mm:ss but now I need to print the data in a pdf file and it should be formatted like "Sunday 8 February 2015" in English, Spanish and Portuguese.
I'm doing this develoment in a Homestrad VM machine.
In the model I have
protected $dates = array('start_at');
Added missing locales in system and checked they are available
locale -a returns
C
C.UTF-8
en_US.utf8
es_ES.uft8
POSIX
pt_BR.utf8
pt_PT.iso88591
pt_PT.utf8
In /etc/default/locale tried
LANG="es_ES.UTF-8", LANG="es_ES.utf8"
LC_ALL="es_ES.UTF-8", LC_ALL="es_ES.utf8"
In the view:
$info->start_at->formatLocalized('%A %d %B %Y');
This is a L4 app and in config\app.php I tried everything I know
'locale' => 'es_ES.UTF-8',
'locale' => 'es_ES.utf8',
It always return the date localized in English and I can't figure out a way to localize the date othe than English.
Thanks in advance.
Please or to participate in this conversation.