You are here

protected function DateBase::parseInputFormat in YAML Form 8

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/YamlFormElement/DateBase.php
Prepare an element to be rendered within a form.

File

src/Plugin/YamlFormElement/DateBase.php, line 209

Class

DateBase
Provides a base 'date' class.

Namespace

Drupal\yamlform\Plugin\YamlFormElement

Code

protected function parseInputFormat(array &$element, $property) {
  if (!isset($element[$property])) {
    return;
  }
  $timestamp = strtotime($element[$property]);
  if ($timestamp === FALSE) {
    $element[$property] = NULL;
  }
  else {
    $element[$property] = \Drupal::service('date.formatter')
      ->format($timestamp, 'html_' . $this
      ->getDateType($element));
  }
}