public static function DateGranularity::limitGranularity in Date 8
Removes unwanted date parts from a date.
In common usage we should not unset timezone through this.
Parameters
array $array: An array of date parts.
File
- date_api/
lib/ Drupal/ date_api/ DateGranularity.php, line 185 - 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 limitGranularity($array) {
foreach (self::$granularity_parts as $key => $val) {
if (!in_array($val, $array)) {
unset($array[$key]);
}
}
return $array;
}