There are a lot of way to do that, you can do it from your controller as :
return Datatables::of($query)
->addColumn('created_at', function ($row){
return $row->created_at->format('d-M-Y');
})
Alternative : Laravel 7 uses a new date serialization format when using the toArray or toJson method on Eloquent models. Previously, dates would be serialized to a format like the following :
2020-12-02 20:01:00
Dates serialized using the ISO-8601 format will appear like :
2020-12-02T20:01:00.283041Z
If you would like to keep using the previous behavior you can override the serializeDate()
method on your model :
use DateTimeInterface;
protected function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
See the official upgrade doc here
CLICK HERE to find out more related problems solutions.