Skip to content

Instantly share code, notes, and snippets.

@DuaelFr
Created November 8, 2013 13:35
Show Gist options
  • Save DuaelFr/7371124 to your computer and use it in GitHub Desktop.
Save DuaelFr/7371124 to your computer and use it in GitHub Desktop.
Set drupal date formats in the code.
<?php
/*
* Implements hook_date_format_types().
*/
function mymodule_date_format_types() {
variable_set('date_format_date_only', 'd/m/Y');
variable_set('date_format_date_only_evt', 'd F Y');
return array(
'date_only' => t('Date only'),
'date_only_evt' => t('Date only event'),
);
}
/*
* Implements hook_date_formats().
*/
function mymodule_date_formats() {
$formats = array();
// Short date formats.
$formats[] = array(
'type' => 'date_only',
'format' => 'd/m/Y',
'locales' => array(),
);
$formats[] = array(
'type' => 'date_only_evt',
'format' => 'd F Y',
'locales' => array(),
);
return $formats;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment