You are here

protected function DateTimeDayDefaultFormatter::formatTime in Date time day 8

Formats the date to time format.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $date: The date to format to time.

Return value

string The formatted time string.

2 calls to DateTimeDayDefaultFormatter::formatTime()
DateTimeDayDefaultFormatter::buildTimeWithAttribute in src/Plugin/Field/FieldFormatter/DateTimeDayDefaultFormatter.php
Creates a render array from a date object with time attribute.
DateTimeDayDefaultFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/DateTimeDayDefaultFormatter.php
Returns a short summary for the current formatter settings.

File

src/Plugin/Field/FieldFormatter/DateTimeDayDefaultFormatter.php, line 109

Class

DateTimeDayDefaultFormatter
Plugin implementation of the 'Default' formatter for 'datetimeday' fields.

Namespace

Drupal\date_time_day\Plugin\Field\FieldFormatter

Code

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