Laravel Date Display created_at All Possible Ways
Hello Coders,
Today's lesson we will learn about display created_at date at different ways in laravel 10 inside blade file. I will clearly explain how can we display dates so that it will be more readable to users. I will discuss from scratch and display all possible output. Let's discover the ways to display dates all ways in laravel 10 in a blade file.
Way 1: Using toFormattedDateString()
{{ $user->created_at->toFormattedDateString() }}
//output: May 18, 2023
Way 2: Using diffForHumans()
{{ $user->created_at->diffForHumans() }}
//output: 3 weeks ago
Way 3: Using toDateString()
{{ $user->created_at->toDateString() }}
//output: 2023-05-18
Way 4: Using toDateTimeString()
{{ $user->created_at->toDateTimeString() }}
//output: 2023-05-18 19:44:37
Way 5: Using toDayDateTimeString()
{{ $user->created_at->toDayDateTimeString() }}
//output: Thu, May 18, 2023 7:44 PM
Way 6: Using toCookieString()
{{ $user->created_at->toCookieString() }}
//output: Thursday, 18-May-2023 19:44:37 UTC
Way 7: Using toIso8601String()
{{ $user->created_at->toIso8601String() }}
//output: 2023-05-18T19:44:37+00:00
Way 8: Using format("Y-m-d")
format() method accepts a custom format compatible with PHP date()
{{ $user->created_at->format("Y-m-d") }}
//output: 2023-05-18
Way 9: Using format("Y/m/d")
{{ $user->created_at->format("Y/m/d") }}
//output: 2023/05/18
Way 10: Using format("Y:m:d")
{{ $user->created_at->format("Y:m:d") }}
//output: 2023:05:18
Thanks. Hope this will easy your task. Please fell free to ask any question about this post.
Test what you just learned with 31 interactive multiple-choice questions and instant explanations.
- Nazmul Hoque
- Updated: Jul 24, 2023
- 2 min read
- 6720
Tags
Share This:
Senior Full-Stack Engineer with 8+ years of experience building production web and mobile applications using Laravel, Next.js, TypeScript, JavaScript, React, Vue.js, MySQL, PostgreSQL, and Flutter.
You May Also Like Below Articles
Handpicked related tutorials and step-by-step developer guides to continue learning.

