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;