public static function DateGranularity::formatOrder in Date 8
Converts a format to an ordered array of granularity parts.
Example: DateGranularity::formatOrder('m/d/Y H:i') returns array( 0 => 'month', 1 => 'day', 2 => 'year', 3 => 'hour', 4 => 'minute', );
Parameters
string $format: A date format string.
Return value
array An array of ordered granularity elements from the given format string.
1 call to DateGranularity::formatOrder()
- DateGranularity::setGranularityFromFormat in date_api/lib/ Drupal/ date_api/ DateGranularity.php 
- Create a granularity array from a date format string.
File
- date_api/lib/ Drupal/ date_api/ DateGranularity.php, line 383 
- Definition of DateGranularity.
Class
- DateGranularity
- This class manages granularity. It can set granularity, get it from an array, get it from a format string, see if the array has any time or date elements, set and unset various granularity parts, create a nongranularity array of the granularity parts…
Namespace
Drupal\date_apiCode
public static function formatOrder($format) {
  $order = array();
  if (empty($format)) {
    return $order;
  }
  $max = strlen($format);
  for ($i = 0; $i <= $max; $i++) {
    if (!isset($format[$i])) {
      break;
    }
    switch ($format[$i]) {
      case 'd':
      case 'j':
        $order[] = 'day';
        break;
      case 'F':
      case 'M':
      case 'm':
      case 'n':
        $order[] = 'month';
        break;
      case 'Y':
      case 'y':
        $order[] = 'year';
        break;
      case 'g':
      case 'G':
      case 'h':
      case 'H':
        $order[] = 'hour';
        break;
      case 'i':
        $order[] = 'minute';
        break;
      case 's':
        $order[] = 'second';
        break;
    }
  }
  return $order;
}