function DateTimeTimeAgoFormatter::formatDate

Same name in other branches
  1. 9 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter::formatDate()
  2. 8.9.x core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter::formatDate()
  3. 10 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeTimeAgoFormatter::formatDate()

Formats a date/time as a time interval.

Parameters

\Drupal\Core\Datetime\DrupalDateTime|object $date: A date/time object.

Return value

array The formatted date/time string using the past or future format setting.

1 call to DateTimeTimeAgoFormatter::formatDate()
DateTimeTimeAgoFormatter::viewElements in core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php
Builds a renderable array for a field value.

File

core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php, line 50

Class

DateTimeTimeAgoFormatter
Plugin implementation of the 'Time ago' formatter for 'datetime' fields.

Namespace

Drupal\datetime\Plugin\Field\FieldFormatter

Code

protected function formatDate(DrupalDateTime $date) {
    return parent::formatTimestamp($date->getTimestamp());
}

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