You are here

protected function DateTimeDefaultFormatter::formatDate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeDefaultFormatter::formatDate()

Creates a formatted date value as a string.

Parameters

object $date: A date object.

Return value

string A formatted date string using the chosen format.

Overrides DateTimeFormatterBase::formatDate

2 calls to DateTimeDefaultFormatter::formatDate()
DateTimeDefaultFormatter::settingsSummary in core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
Returns a short summary for the current formatter settings.
DateTimeDefaultFormatter::viewElements in core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php
Builds a renderable array for a field value.

File

core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php, line 90
Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeDefaultFormatter.

Class

DateTimeDefaultFormatter
Plugin implementation of the 'Default' formatter for 'datetime' fields.

Namespace

Drupal\datetime\Plugin\Field\FieldFormatter

Code

protected function formatDate($date) {
  $format_type = $this
    ->getSetting('format_type');
  $timezone = $this
    ->getSetting('timezone_override');
  return $this->dateFormatter
    ->format($date
    ->getTimestamp(), $format_type, '', $timezone != '' ? $timezone : NULL);
}