diff --git a/Entity/CacheRepository.php b/Entity/CacheRepository.php index 2d54f56e..bb6b1d16 100644 --- a/Entity/CacheRepository.php +++ b/Entity/CacheRepository.php @@ -118,13 +118,13 @@ public function findLimit( public function oldestDateAdded($duration, string $timezone = null, \DateTime $dateSend = null) { $oldest = $dateSend ? $dateSend : new \DateTime(); + if (!$timezone) { + $timezone = date_default_timezone_get(); + } + $oldest->setTimezone(new \DateTimeZone($timezone)); if (0 !== strpos($duration, 'P')) { // Non-rolling interval, go to previous interval segment. // Will only work for simple (singular) intervals. - if (!$timezone) { - $timezone = date_default_timezone_get(); - } - $oldest->setTimezone(new \DateTimeZone($timezone)); switch (strtoupper(substr($duration, -1))) { case 'Y': $oldest->modify('next year jan 1 midnight');