You are here

public function NodeViewCountRecordsManager::deleteOldRecords in Node view count 8

Delete old nodeviewcount records from database.

Parameters

int $time: Lifetime of the records in milliseconds.

Overrides NodeViewCountRecordsManagerInterface::deleteOldRecords

File

src/NodeViewCountRecordsManager.php, line 93

Class

NodeViewCountRecordsManager
Provides a class for interacting with nodeviewcount records.

Namespace

Drupal\nodeviewcount

Code

public function deleteOldRecords($time) {
  $timeZone = date_default_timezone_get();
  $timeNow = new DrupalDateTime('NOW', $timeZone);
  $unixDate = strtotime($timeNow) - $time;
  $this->connection
    ->delete('nodeviewcount')
    ->condition('datetime', $unixDate, '<')
    ->execute();
}