prepare('SELECT * FROM spo2 WHERE timestamp_utc >= ?'); $pq->execute(array($servefrom)); $res = $pq->fetchAll(); #header('Content-Type: text/plain'); header('Content-Type: application/json'); $result = array(); foreach ($res as $row) { $dto = new DateTime('@' . $row['timestamp_utc'], new DateTimeZone('UTC')); $result[] = array( 'unixtime' => intval($row['timestamp_utc']), #'datestr' => $dto->format('Y.m.d \A\D \a\t H:i:s \U\T\C'), 'datestr' => $dto->format('c'), 'spo2_value' => intval($row['spo2_percent']), 'spo2_confidence' => intval($row['spo2_confidence']), ); } #var_dump($result); echo json_encode($result);