Reputation:
how to convert timestamp into following format 03 Dec 2015
DB timestamp 2015-12-03 05:23:08
this is what i tried
<td>{{ date('d/m/Y', strtotime($user->created_at)) }}</td>
but i dnt know how to get month with 3 words . pls advice
Upvotes: 1
Views: 15526
Reputation: 339
The easier way is to format it in the model for laravel 6
and above using the below casting feature
protected $casts = [
'created_at' => 'datetime:Y-m-d',
'updated_at' => 'datetime:Y-m-d',
'deleted_at' => 'datetime:Y-m-d h:i:s'
];
You can add any format you prefer in the $casts array
Upvotes: 0
Reputation: 556
created_at should be an instance of carbon. Then you can do:
{{ $user->created_at->format('d M Y') }}
Upvotes: 4
Reputation: 16963
You can do something like this:
<td>{{ strftime("%d %b %Y",strtotime($user->created_at)) }}</td>
Or,
<td>{{ date("d M Y", strtotime($user->created_at)) }}</td>
Upvotes: 6