I am trying to get date values from a JSON in PHP:
{
"data": [
{
"start": {
"date": "2019-12-27 21:05:28.073000",
"timezone_type": 3,
"timezone": "UTC"
},
"final": {
"date": "2019-12-28 20:59:43.153000",
"timezone_type": 3,
"timezone": "UTC"
}
}
]
}
My PHP code is trying to read the JSON but I guess that I do not reach the start and final sublevels.
I get an error and nothing is returned.
I am trying to get in one variable "2019-12-27 21:05:28 UTC+3" (start) and in another one "2019-12-28 20:59:43 UTC+3" (final)
<?php
$json=file_get_contents("https://XXX/myjson.php");
$data = json_decode($json);
if (count($data->data)) {
// Open the table
// Cycle through the array
foreach ($data->data as $idx => $stand) {
echo "first operation ".$stand->start."<br>";
echo "final operation ".$stand->final;
}}
?>