Laravel – displaying created_at updated_at value in view

Last Updated: May 17, 2021

When you try to display the value of created_at updated_at in blade view you may find some issues.

You can see this error

following error: date() expects parameter 2 to be long, object given. So I use dd() on $object->created_at

This is because Laravel use Carbon

So you can use the following code to fix that

{{ date('d M Y - H:i:s', $product->created_at->timestamp) }}
{{ $product->created_at->format('d M Y - H:i:s') }}