'Change created_at & updated_at values on API response
Currently Getting This :-
"created_at": "2022-03-26T09:08:44.000000Z",
"updated_at": "2022-03-26T09:08:44.000000Z",
But Need This :-
"created_at": "2022-03-26 09:08:44",
"updated_at": "2022-03-26 09:08:44",
Thanks In Advance
Solution 1:[1]
The perfect solution for your question is already present in the laravel documentation
/**
* Prepare a date for array / JSON serialization.
*
* @param \DateTimeInterface $date
* @return string
*/
protected function serializeDate(DateTimeInterface $date)
{
return $date->format('Y-m-d H:i:s');
}
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 | N69S |
