I am building an API and I would like to return all my timestamps like created_at, deleted_at, ... and so on as complex objects including the actual datetime, but also the timezone. I am already using {Carbon/Carbon}in my Controller. I defined my date field in the model as well. When I access the date fields in my controller, I actually get Carbon objects. But when I return my result set as JSON, I only see the datetime string. Not the timezone.
Current JSON
{
"id": 4,
"username": "purusScarlett93",
"firstname": null,
"lastname": null,
"language_id": 1,
"pic": null,
"email": null,
"authtoken": "f54e17b2ffc7203afe345d947f0bf8ceab954ac4f08cc19990fc41d53fe4eef8",
"authdate": "2015-05-27 12:31:13",
"activation_code": null,
"active": 0,
"devices": [],
"sports": []
}
My wish :)
{
"id": 4,
"username": "purusScarlett93",
"firstname": null,
"language_id": 1,
"pic": null,
"email": null,
"authtoken":"f54e17b2ffc7203afe41d53fe4eef8",
"authdate": [
{
"datetime": "2015-05-27 12:31:13",
"timezone": "UTC+2"
}
],
"activation_code": null,
"active": 0
}
Any idea what I am missing here?