You are here

protected function DateTimeTimeAgoFormatter::formatDate in Drupal 9

Same name and namespace in other branches
  1. 8 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 49

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());
}