You are here

protected function DevelController::showTimeAndTimeAgo in Search API Solr 8.3

Same name and namespace in other branches
  1. 8.2 search_api_solr_devel/src/Controller/DevelController.php \Drupal\search_api_solr_devel\Controller\DevelController::showTimeAndTimeAgo()
  2. 4.x modules/search_api_solr_devel/src/Controller/DevelController.php \Drupal\search_api_solr_devel\Controller\DevelController::showTimeAndTimeAgo()

Given a timestamp it returns both a human-readable date + "time ago".

Parameters

int $timestamp: A UNIX timestamp to display.

Return value

\Drupal\Core\StringTranslation\TranslatableMarkup The formatted timestamp.

2 calls to DevelController::showTimeAndTimeAgo()
DevelController::entitySolr in modules/search_api_solr_devel/src/Controller/DevelController.php
Prints the document structure to be indexed by Solr.
DevelController::getBaseRow in modules/search_api_solr_devel/src/Controller/DevelController.php
Return a base row for the summary table, which will be modified later on.

File

modules/search_api_solr_devel/src/Controller/DevelController.php, line 301

Class

DevelController
Returns responses for devel module routes.

Namespace

Drupal\search_api_solr_devel\Controller

Code

protected function showTimeAndTimeAgo($timestamp) {
  return $this
    ->t('%time (%time_ago ago)', [
    '%time' => $this->dateFormatter
      ->format($timestamp),
    '%time_ago' => $this->dateFormatter
      ->formatDiff($timestamp, $this->time
      ->getRequestTime()),
  ]);
}