function DateTimePlainFormatter::formatDate
Same name in other branches
- 9 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimePlainFormatter::formatDate()
- 8.9.x core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimePlainFormatter::formatDate()
- 11.x core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimePlainFormatter::formatDate()
Overrides DateTimeFormatterBase::formatDate
File
-
core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimePlainFormatter.php, line 44
Class
- DateTimePlainFormatter
- Plugin implementation of the 'Plain' formatter for 'datetime' fields.
Namespace
Drupal\datetime\Plugin\Field\FieldFormatterCode
protected function formatDate($date) {
$format = $this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::DATE_STORAGE_FORMAT : DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
$timezone = $this->getSetting('timezone_override') ?: $date->getTimezone()
->getName();
return $this->dateFormatter
->format($date->getTimestamp(), 'custom', $format, $timezone != '' ? $timezone : NULL);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.