Skip to content

Commit

Permalink
Merge pull request #5894 from WoltLab/bugfix/search-time
Browse files Browse the repository at this point in the history
Set the correct time for `$endDate` and `$startDate`
  • Loading branch information
Cyperghost authored Apr 26, 2024
2 parents 70508f6 + 2fa0ae0 commit 9d555b2
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions wcfsetup/install/files/lib/system/search/SearchHandler.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,30 @@ private function buildUserCondition(): void

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) {
Expand Down

0 comments on commit 9d555b2

Please sign in to comment.