protected function DateBase::parseInputFormat in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElement/DateBase.php \Drupal\webform\Plugin\WebformElement\DateBase::parseInputFormat()
Parse GNU Date Input Format.
Parameters
array $element: An element.
string $property: The element's date property.
1 call to DateBase::parseInputFormat()
- DateBase::prepare in src/
Plugin/ WebformElement/ DateBase.php - Prepare an element to be rendered within a webform.
File
- src/
Plugin/ WebformElement/ DateBase.php, line 377
Class
- DateBase
- Provides a base 'date' class.
Namespace
Drupal\webform\Plugin\WebformElementCode
protected function parseInputFormat(array &$element, $property) {
if (!isset($element[$property])) {
return;
}
elseif (is_array($element[$property])) {
foreach ($element[$property] as $key => $value) {
$timestamp = strtotime($value);
$element[$property][$key] = $timestamp ? \Drupal::service('date.formatter')
->format($timestamp, 'html_' . $this
->getDateType($element)) : NULL;
}
}
else {
$timestamp = strtotime($element[$property]);
$element[$property] = $timestamp ? \Drupal::service('date.formatter')
->format($timestamp, 'html_' . $this
->getDateType($element)) : NULL;
}
}