protected function DateRangeAllDayCustomFormatter::formatDate in Date all day 8
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 DateTimeCustomFormatter::formatDate
File
- src/
Plugin/ Field/ FieldFormatter/ DateRangeAllDayCustomFormatter.php, line 55
Class
- DateRangeAllDayCustomFormatter
- Plugin implementation of the 'Custom' formatter for 'daterange' fields.
Namespace
Drupal\date_all_day\Plugin\Field\FieldFormatterCode
protected function formatDate($date, $all_day = FALSE) {
$format_setting_name = $all_day ? 'date_only_format' : 'date_format';
$format = $this
->getSetting($format_setting_name);
$timezone = $this
->getSetting('timezone_override');
return $this->dateFormatter
->format($date
->getTimestamp(), 'custom', $format, $timezone != '' ? $timezone : NULL);
}