From 044444eaa8bb597bca9d4a50d5614b6aa2e3a2c6 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Tue, 13 Jan 2026 08:34:59 +0900 Subject: [PATCH] door: fix data extraction --- src/pvv/side/door.php | 2 +- www/door/index.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pvv/side/door.php b/src/pvv/side/door.php index cde184c..c4282b1 100644 --- a/src/pvv/side/door.php +++ b/src/pvv/side/door.php @@ -39,7 +39,7 @@ class Door { $query = 'SELECT time, open FROM door WHERE time > :startTime ORDER BY time DESC'; $statement = $this->pdo->prepare($query); - $statement->bindParam(':startTime', $startTime, \PDO::PARAM_STR); + $statement->bindParam(':startTime', $startTime->getTimestamp(), \PDO::PARAM_INT); $statement->execute(); $doorEvents = []; diff --git a/www/door/index.php b/www/door/index.php index d39831d..e0f0599 100644 --- a/www/door/index.php +++ b/www/door/index.php @@ -31,9 +31,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $period = (string) htmlspecialchars($_GET['period']); if ($period == 'day') { - $startTime = time() - (60 * 60 * 24); + $startTime = (new \DateTimeImmutable()) + ->setTimestamp(time()) + ->sub(new \DateInterval('P1D')); } elseif ($period == 'week') { - $startTime = time() - (60 * 60 * 24 * 7); + $startTime = (new \DateTimeImmutable()) + ->setTimestamp(time()) + ->sub(new \DateInterval('P1W')); } else { echo '{"status": "error", "message": "Invalid period"}'; exit;