You are here

function _optimizedb_date in OptimizeDB 8

Same name and namespace in other branches
  1. 6 optimizedb.module \_optimizedb_date()
  2. 7 optimizedb.module \_optimizedb_date()

Output how much time passed from the specified date.

Parameters

int $timestamp: The date in Unix format.

Return value

string The formatted date.

2 calls to _optimizedb_date()
OptimizedbAdminForm::buildForm in src/Form/OptimizedbAdminForm.php
Form constructor.
optimizedb_requirements in ./optimizedb.install
Implements hook_requirements().

File

./optimizedb.module, line 168
Database Optimization.

Code

function _optimizedb_date($timestamp) {
  $timestamp = (int) $timestamp;
  if ($timestamp == 0) {
    return t('None');
  }
  $difference = \Drupal::time()
    ->getRequestTime() - $timestamp;
  $text = \Drupal::service('date.formatter')
    ->formatInterval($difference, 1);
  return $text;
}