protected static function Datetime::getHtml5DateFormat

protected static Datetime::getHtml5DateFormat($element)

Retrieves the right format for a HTML5 date element.

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

Parameters

string $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.

File

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

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'];
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Datetime!Element!Datetime.php/function/Datetime::getHtml5DateFormat/8.1.x