function DateTimeFormatterBase::buildDate
Same name in other branches
- 9 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeFormatterBase::buildDate()
- 8.9.x core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeFormatterBase::buildDate()
- 10 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimeFormatterBase::buildDate()
Creates a render array from a date object.
Parameters
\Drupal\Core\Datetime\DrupalDateTime $date: A date object.
Return value
array A render array.
4 calls to DateTimeFormatterBase::buildDate()
- DateRangeCustomFormatter::viewElements in core/
modules/ datetime_range/ src/ Plugin/ Field/ FieldFormatter/ DateRangeCustomFormatter.php - DateRangePlainFormatter::viewElements in core/
modules/ datetime_range/ src/ Plugin/ Field/ FieldFormatter/ DateRangePlainFormatter.php - DateTimeCustomFormatter::viewElements in core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimeCustomFormatter.php - DateTimePlainFormatter::viewElements in core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimePlainFormatter.php
File
-
core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimeFormatterBase.php, line 202
Class
- DateTimeFormatterBase
- Base class for 'DateTime Field formatter' plugin implementations.
Namespace
Drupal\datetime\Plugin\Field\FieldFormatterCode
protected function buildDate(DrupalDateTime $date) {
$this->setTimeZone($date);
$build = [
'#markup' => $this->formatDate($date),
'#cache' => [
'contexts' => [
'timezone',
],
],
];
return $build;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.