public function formatDate($date, $format = 'medium', $timezone = null, $langcode = null) { $timestamp = $this->dateToTimestamp($date); if (null === $timestamp) { return ''; // I'm really sorry I'm not Mme Irma } $drupalDateTypes = system_get_date_types(); if (isset($drupalDateTypes[$format])) { $formatted = format_date($timestamp, $format, '', $timezone, $langcode); } else { $formatted = format_date($timestamp, 'custom', $format, $timezone, $langcode); } return $formatted; }
function date_format_type_options() { $options = array(); $format_types = system_get_date_types(); if (!empty($format_types)) { foreach ($format_types as $type => $type_info) { $options[$type] = $type_info['title']; } } return $options; }