Saves a date format to the database.
string $date_format_id: If set, replace the existing date format having this ID with the information specified in $format_info.
array $format_info: A date format array containing the following keys:
function system_date_format_save($date_format_id, $format_info) {
config('system.date')
->set('formats.' . $date_format_id, $format_info)
->save();
$languages = language_list();
$locale_format = array(
'name' => $format_info['name'],
'pattern' => $format_info['pattern'],
);
// Check if the suggested language codes are configured.
if (!empty($format_info['locales'])) {
foreach ($format_info['locales'] as $langcode) {
if (isset($languages[$langcode])) {
config('locale.config.' . $langcode . '.system.date')
->set('formats.' . $date_format_id, $locale_format)
->save();
}
}
}
}