You are here

protected static function Datetime::getHtml5DateFormat in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Datetime/Element/Datetime.php \Drupal\Core\Datetime\Element\Datetime::getHtml5DateFormat()

Retrieves the right format for a HTML5 date element.

The format is important because these elements will not work with any other format.

Parameters

array $element: The $element to assess.

Return value

string Returns the right format for the date element, or the original format if this is not a HTML5 element.

3 calls to Datetime::getHtml5DateFormat()
Datetime::processDatetime in core/lib/Drupal/Core/Datetime/Element/Datetime.php
Expands a datetime element type into date and/or time elements.
Datetime::validateDatetime in core/lib/Drupal/Core/Datetime/Element/Datetime.php
Validation callback for a datetime element.
Datetime::valueCallback in core/lib/Drupal/Core/Datetime/Element/Datetime.php
Determines how user input is mapped to an element's #value property.

File

core/lib/Drupal/Core/Datetime/Element/Datetime.php, line 411

Class

Datetime
Provides a datetime element.

Namespace

Drupal\Core\Datetime\Element

Code

protected static function getHtml5DateFormat($element) {
  switch ($element['#date_date_element']) {
    case 'date':
      return DateFormat::load('html_date')
        ->getPattern();
    case 'datetime':
    case 'datetime-local':
      return DateFormat::load('html_datetime')
        ->getPattern();
    default:
      return $element['#date_date_format'];
  }
}