In a Blade view I have this code
{{ \Carbon\Carbon::setLocale("es") }}
{{ $registro->fecha_desde->format("l j F Y") }}<br />
{{ $registro->fecha_desde->formatLocalized("%A %d %B %Y") }}<br />
{{ $registro->fecha_desde->diffForHumans() }}
This does not work, it returns:
Friday 30 December 2016
Friday 30 December 2016
dentro de 1 semana
So, format() and formatLocalized always returns the date in english format. diffForHumans returns the date localized (in spanish in this case).
Am I missing something? cant believe "Carbon's formatLocalized" is not returning localized formated dates....
Found it. The problems is \Carbon::setlocale()
This looks ugly but works:
Output: