You are here

function date_format_type_options in Date 8

Same name and namespace in other branches
  1. 7.3 date_api/date_api.module \date_format_type_options()
  2. 7 date_api/date_api.module \date_format_type_options()
  3. 7.2 date_api/date_api.module \date_format_type_options()

Creates an array of date format types for use as an options list.

4 calls to date_format_type_options()
DateDefaultFormatter::settingsForm in lib/Drupal/date/Plugin/field/formatter/DateDefaultFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
DateDefaultFormatter::settingsSummary in lib/Drupal/date/Plugin/field/formatter/DateDefaultFormatter.php
Settings summary for the default formatter.
DateFieldDefaultFormatter::settingsForm in date_field/lib/Drupal/date_field/Plugin/field/formatter/DateFieldDefaultFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
DateFieldDefaultFormatter::settingsSummary in date_field/lib/Drupal/date_field/Plugin/field/formatter/DateFieldDefaultFormatter.php
Settings summary for the default formatter.

File

date_api/date_api.module, line 485
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_format_type_options() {
  $options = array();
  $time = date_example_date();
  $format_types = system_get_date_types();
  if (!empty($format_types)) {
    foreach ($format_types as $type => $type_info) {
      $options[$type] = $type_info['title'] . ' (' . format_date($time
        ->format('U'), $type) . ')';
    }
  }
  return $options;
}