PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE davisvp ( id INT AUTO_INCREMENT PRIMARY KEY, DateTime DATETIME NOT NULL, T FLOAT NOT NULL ); INSERT INTO davisvp (DateTime, T) VALUES ('2024-12-03 00:01:32', 17.5), ('2024-12-03 01:01:53', 16.3), ('2024-12-03 02:02:14', 15.6), ('2024-12-03 03:02:33', 15.1), ('2024-12-03 04:03:14', 14.4), ('2024-12-03 05:03:56', 14.0), ('2024-12-03 06:04:18', 14.1), ('2024-12-03 07:04:38', 16.0), ('2024-12-03 08:05:19', 18.5), ('2024-12-03 09:05:58', 21.7), ('2024-12-03 10:06:40', 24.1), ('2024-12-03 11:07:22', 26.9), ('2024-12-03 12:07:43', 28.3), ('2024-12-03 13:08:23', 29.6), ('2024-12-03 14:08:45', 30.6), ('2024-12-03 15:09:05', 31.1), ('2024-12-03 16:09:24', 31.8);
Copy Clear
Copy Format Clear
<?php $sql = <<<SQL SELECT DateTime, MAX(T) as max_temperature FROM davisvp WHERE DATE(DateTime) = CURDATE() GROUP BY HOUR(DateTime) SQL; echo json_encode( [ 'name' => 'temperature', 'data' => array_map( fn($row) => [strtotime($row['DateTime']) * 1000, (float) $row['max_temperature']], $mysqli->query($sql)->fetch_all(MYSQLI_ASSOC) ], JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT );
Show:  
Copy Clear