Good day to all, I want to make sure that the formatted date time is displayed in different language except for default English, say, in French. The code:
<small> {{$income->created_at->format('F jS, Y')}}</small>
.
How is it possible to achieve?
Good day to all, I want to make sure that the formatted date time is displayed in different language except for default English, say, in French. The code:
<small> {{$income->created_at->format('F jS, Y')}}</small>
.
How is it possible to achieve?
Laravel uses Carbon under the hood for date operations. Carbon has several functions to localize datetime formats for different languages.
What you are looking for is isoFormat
. This function expects the same parameters as php's own strftime
function.
You can use locale
method to set the localization in your app.
{{$income->created_at->locale('fr_FR')->format('F jS, Y')}}
For more information have a look on the API https://carbon.nesbot.com/docs/#api-localization
The ->locale() method only change the language for the current instance and has precedence over global settings.
You can also try
{{Carbon\Carbon::parse($income->created_at)->locale('fr_FR')->format('F jS, Y')}}