/** * Filter collection by created at date older than specified seconds before now * * @param int $secondsBeforeNow * @return $this */ public function addCreatedAtBeforeFilter($secondsBeforeNow) { $datetime = new \DateTime('now', new \DateTimeZone('UTC')); $storeInterval = new \DateInterval('PT' . $secondsBeforeNow . 'S'); $datetime->sub($storeInterval); $formattedDate = $this->dateTime->formatDate($datetime->getTimestamp()); $this->addFieldToFilter(Log::CREATED_AT_FIELD_NAME, ['lt' => $formattedDate]); return $this; }