I dont know why, when I tried to call eloquent always get created_at and updated_at extra weird text. So 2020-07-25 10:05:25
it changed to 2020-07-25T10:05:25.000000Z
. Here is it my eloquent Article::with('category')->get()->toJson()
, i want to keep updated_at and created_at as 2020-07-25 10:05:25
.Any idea to solve this problem?
I solved my own problem with adding this to my model
public function getCreatedAtAttribute($value){
$date = Carbon::parse($value);
return $date->format('Y-m-d H:i');
}
public function getUpdatedAtAttribute($value){
$date = Carbon::parse($value);
return $date->format('Y-m-d H:i');
}