protected function TimeFormatter::viewValue in Time Field For Drupal 8.x / 9.x 8
Same name and namespace in other branches
- 2.x src/Plugin/Field/FieldFormatter/TimeFormatter.php \Drupal\time_field\Plugin\Field\FieldFormatter\TimeFormatter::viewValue()
Generate the output appropriate for one field item.
Parameters
\Drupal\Core\Field\FieldItemInterface $item: One field item.
Return value
string The textual output generated.
1 call to TimeFormatter::viewValue()
- TimeFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ TimeFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ TimeFormatter.php, line 33
Class
- TimeFormatter
- Plugin implementation of the 'time_formatter' formatter.
Namespace
Drupal\time_field\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
$time = Time::createFromTimestamp($item->value);
return $time
->format($this
->getSetting('time_format'));
}