Created
December 13, 2013 10:37
-
-
Save jonhattan/7942525 to your computer and use it in GitHub Desktop.
Snippet to create date formats in Drupal.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Array of type => format. | |
$formats = array( | |
'day_monthname_year' => 'j \d\e F \d\e Y', | |
'weekday_day_monthname_year' => 'l j \d\e F \d\e Y', | |
); | |
$query_types = db_insert('date_format_type')->fields(array('type', 'title')); | |
$query_formats = db_insert('date_formats')->fields(array('format', 'type')); | |
foreach ($formats as $type => $format) { | |
$query_types->values(array( | |
'type' => $type, | |
'title' => $type, | |
)); | |
$query_formats->values(array( | |
'format' => $format, | |
'type' => 'custom', | |
)); | |
variable_set('date_format_' . $type, $format); | |
} | |
$query_types->execute(); | |
$query_formats->execute(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment