You are here

protected function VisitorsBlock::_showSinceDate in Visitors 8.2

Display the start date statistics to visitors block.

1 call to VisitorsBlock::_showSinceDate()
VisitorsBlock::build in src/Plugin/Block/VisitorsBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/VisitorsBlock.php, line 154
Contains \Drupal\visitors\Plugin\Block\VisitorsBlock.

Class

VisitorsBlock
Provides a 'Visitors' block.

Namespace

Drupal\visitors\Plugin\Block

Code

protected function _showSinceDate() {
  if ($this->config
    ->get('show_since_date')) {
    $query = \Drupal::database()
      ->select('visitors');
    $query
      ->addExpression('MIN(visitors_date_time)');
    $since_date = $query
      ->execute()
      ->fetchField();
    $this->items[] = t('Since: %since_date', array(
      '%since_date' => \Drupal::service('date.formatter')
        ->format($since_date, 'short'),
    ));
  }
}