protected function DateTimePlainFormatter::formatDate in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimePlainFormatter::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
1 call to DateTimePlainFormatter::formatDate()
- DateTimePlainFormatter::viewElements in core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimePlainFormatter.php - Builds a renderable array for a field value.
File
- core/
modules/ datetime/ src/ Plugin/ Field/ FieldFormatter/ DateTimePlainFormatter.php, line 63 - Contains \Drupal\datetime\Plugin\Field\FieldFormatter\DateTimePlainFormatter.
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') == 'date' ? DATETIME_DATE_STORAGE_FORMAT : DATETIME_DATETIME_STORAGE_FORMAT;
$timezone = $this
->getSetting('timezone_override');
return $this->dateFormatter
->format($date
->getTimestamp(), 'custom', $format, $timezone != '' ? $timezone : NULL);
}