Programmatically creating date formats

Public

</> CopyGet raw version
php
  1. /**
  2. * Implements hook_date_format_types().
  3. */
  4. function hook_date_format_types() {
  5. return array(
  6. 'my_format' => t('My format'),
  7. );
  8. }
  9. /**
  10. * Implements hook_date_formats().
  11. */
  12. function hook_date_formats() {
  13. $formats = array();
  14. $formats[] = array(
  15. 'type' => 'my_format',
  16. 'format' => 'M j',
  17. 'locales' => array(),
  18. );
  19. foreach ($formats as $format) {
  20. variable_set('date_format_' . $format['type'], $format['format']);
  21. }
  22. return $formats;
  23. }