'Convert timestamp into custom format Laravel

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



Solution 1:[1]

created_at should be an instance of carbon. Then you can do:

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 rammelmueller