Reputation: 857
In my app I just set timezone
as UTC
when I return response I got date format as UTC
.
"created_at": {
"date": "2018-05-18 15:17:37.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updated_at": {
"date": "2018-06-08 05:49:05.000000",
"timezone_type": 3,
"timezone": "UTC"
}
But I only need updated_at : 2018-06-08 05:49:05
, I do not need timzone type, timezone
..
Expected :
"country" : "United States Of America",
"region" : "Northeast",
"updated_at": "2018-06-08 05:49:05"
How can i do this ?
Upvotes: 1
Views: 1346
Reputation: 5452
Take a look at this
https://laravel.com/docs/5.6/eloquent-mutators#date-mutators
You can do this by using an accessor method in your model and the time format you want.
To format date and time easily, use Carbon
Upvotes: 2