When you want to change the format for date&time in Laravel blade files, you can use "format" method.
The conditions are as below.
- Column name is "updated_at" and its data type for this column is timestamp (ex: "2022-03-22 04:55:01") -In blade file, iterate the variables that is passed by the controller (ex:$post).
<div class="col-4">
{{$post->updated_at->format('Y/m/d')}}
</div>
What you get in the web browser is as below.("-" is replaced by "/.")
2022/03/22
"Format" method from Carbon class works, too. You create a carbon instance by "Carbon\Carbon::parse()," and then specify the format('Y/m/d') by format method.
<div class="col-4">
{{Carbon\Carbon::parse($quotes->created_at)->format('Y/m/d')}}
</div>
To parse date is to take string representation of a date, and returns a unix timestamp.
Top comments (0)