function datetime_default_format_type

Retrieves the correct datetime format type for this system.

This value is sometimes required when the format type needs to be determined before a date can be created.

Return value

string A string as defined in \DrupalComponent\Datetime\DateTimePlus.php: either 'intl' or 'php', depending on whether IntlDateFormatter is available.

Related topics

3 calls to datetime_default_format_type()
DateTimeDefaultWidget::formElement in drupal/core/modules/datetime/lib/Drupal/datetime/Plugin/field/widget/DatetimeDefaultWidget.php
Implements \Drupal\field\Plugin\Type\Widget\WidgetInterface::formElement().
datetime_element_info in drupal/core/modules/datetime/datetime.module
Implements hook_element_info().
datetime_html5_format in drupal/core/modules/datetime/datetime.module
Retrieves the right format for a HTML5 date element.

File

drupal/core/includes/common.inc, line 1345
Common functions that many Drupal modules will need to reference.

Code

function datetime_default_format_type() {
  static $drupal_static_fast;
  if (!isset($drupal_static_fast)) {
    $drupal_static_fast['format_type'] =& drupal_static(__FUNCTION__);
  }
  $format_type =& $drupal_static_fast['format_type'];
  if (!isset($format_type)) {
    $date = new DrupalDateTime();
    $format_type = $date
      ->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP;
  }
  return $format_type;
}