Skip to content

How can I display a formatted date in Laravel Blade? #56676

Answered by victormoni
rrsilvabr asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @rrsilvabr 👋😄

You can use Carbon, which comes integrated with Laravel to handle dates. In your Blade file, you can do this:

{{ \Carbon\Carbon::parse($user->created_at)->format('d/m/Y') }}

Or, if you already have a date object (Eloquent automatically returns created_at as a Carbon instance), you can simply do:

{{ $user->created_at->format('d/m/Y') }}

This way, Laravel uses Carbon under the hood to format the date.

Reference: Laravel Docs - Dates

I hope it helps 🙏

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rrsilvabr
Comment options

Answer selected by rrsilvabr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants