From 2fa0ae0b8d1c8a9ac1060560a10f36d9c090b0a1 Mon Sep 17 00:00:00 2001 From: Cyperghost Date: Fri, 26 Apr 2024 11:43:50 +0200 Subject: [PATCH] Set the correct time for `$endDate` and `$startDate` --- .../lib/system/search/SearchHandler.class.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/search/SearchHandler.class.php b/wcfsetup/install/files/lib/system/search/SearchHandler.class.php index ca4ca09449..63971a7de7 100644 --- a/wcfsetup/install/files/lib/system/search/SearchHandler.class.php +++ b/wcfsetup/install/files/lib/system/search/SearchHandler.class.php @@ -144,8 +144,30 @@ final class SearchHandler private function buildDateCondition(): void { - $startDate = !empty($this->parameters['startDate']) ? @\strtotime($this->parameters['startDate']) : 0; - $endDate = !empty($this->parameters['endDate']) ? @\strtotime($this->parameters['endDate']) : 0; + if (!empty($this->parameters['startDate'])) { + $startDateTime = \DateTime::createFromFormat( + "Y-m-d", + $this->parameters['startDate'], + WCF::getUser()->getTimezone() + ); + $startDateTime->setTime(0, 0, 0); + $startDate = $startDateTime->getTimestamp(); + } else { + $startDate = 0; + } + + if (!empty($this->parameters['endDate'])) { + $endDateTime = \DateTime::createFromFormat( + "Y-m-d", + $this->parameters['endDate'], + WCF::getUser()->getTimezone() + ); + $endDateTime->setTime(23, 59, 59); + $endDate = $endDateTime->getTimestamp(); + } else { + $endDate = 0; + } + if ($startDate && $endDate) { $this->conditionBuilder->add('time BETWEEN ? AND ?', [$startDate, $endDate]); } elseif ($startDate) { -- 2.20.1