function olivero_preprocess_comment

Same name in other branches
  1. 9 core/themes/olivero/olivero.theme \olivero_preprocess_comment()
  2. 11.x core/themes/olivero/olivero.theme \olivero_preprocess_comment()

Implements hook_preprocess_HOOK() for comment.html.twig.

File

core/themes/olivero/olivero.theme, line 517

Code

function olivero_preprocess_comment(&$variables) {
    // Getting the node creation time stamp from the comment object.
    $date = $variables['comment']->getCreatedTime();
    // Formatting "created" as "X days ago".
    $variables['created'] = t('@time ago', [
        '@time' => \Drupal::service('date.formatter')->formatInterval(\Drupal::time()->getRequestTime() - $date),
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.