In my toJSON() function I display certain values in them a datetime. Example:
"gps": [
{
"serie": "12345",
"name": "MasterK10",
"dateUpdate": {
"date": "2018-07-04 00:00:00.000000",
"timezone_type": 3,
"timezone": "Europe/Berlin"
}
]
I want it to just display like this:
"gps": [
{
"serie": "12345",
"name": "MasterK10",
"dateUpdate": "2018-07-04 00:00:00.000000",
]
I add my method and the image of the query in SQL-Server
public function toJson() {
return json_encode(array(
'serie' => $this->serie,
'name' => $this->name,
'dateUpdate' => $this->dateUpdate,
'location' => json_decode($this->location->toJson()),
'status' => $this->status
));
}
You could get the array
$this->dateUpdate
and assign another variable with the string, so that it looks like this:You can access the property
dateUpdate.update
directly like this:I hope it helps you, greetings
It worked for me with this code:
Thank you all.