I have a custom date format defined (via code), and this is what I see in the administration pages:

Custom Date Formats (png screenshot)

In views, I've attached a field, and trying to use a formatter, but they're all showing up like this:

Views Date Format (png screenshot)

I can't seem to select my m/d/y feature, and even the default (short, medium and long) are strange. I have tried clearing caches, and the usual. The view is being exported with a feature, and I have not tried recreating it, yet. Any ideas?

Here's the code generating the custom date format:

 * Implements hook_date_formats().
function custom_date_formats()
  $formats = array();

  $formats[] = array(
      'type' => 'm_d_y',
      'format' => 'm/d/Y',
      'locales' => array(),

  return $formats;

 * Implements hook_date_format_types().
function custom_date_format_types()
  return array(
      'm_d_y' => t('m/d/Y'),
  • if you try to disable/remove your custom date format, the default Drupal format (short, medium and long) will still show incorrect format "like what you have in the second screenshot"?
    – Aboodred1
    Feb 21, 2013 at 17:25
  • My custom date format is defined programmatically, so I can't disable it via the UI. It does work on another environment though.
    – Foo
    Feb 21, 2013 at 17:35
  • can you post your custom date format code?!
    – Aboodred1
    Feb 21, 2013 at 17:47
  • See the original post for the code.
    – Foo
    Feb 21, 2013 at 17:57
  • once I applied your code the first time, I got the same results as yours in the views, then I added a custom date format with the same format from the UI and then tried views again; it seems to work the right way (as expected) i don't know why.
    – Aboodred1
    Feb 21, 2013 at 18:27

2 Answers 2


I still did not find the answer to this problem, but fixed it. I fixed it by simply saving the custom date format form in Date & Time in Drupal. Simply submitting that form, without making any changes, refreshed the Drupal views, and it started working properly.

I will look into the submit handler to see what caused the problem, and post if I find anything.

  • did you ever find out what was causing this?
    – Adam
    Nov 7, 2013 at 21:15
  • No, I never found out what caused it.
    – Foo
    Nov 8, 2013 at 22:29

In my case, I had to manually do what you did AND ALSO manually set a variable using variable_set().

For example, if (as in your example) your date format's "type" is "m_d_y" and the format is "m/d/Y" then you'd need to do:

variable_set('date_format_m_d_y', 'm/d/Y');

After that, the Views should start working, and no manual work is required like saving a form.

That said, this doesn't seem ideal, and I'm wondering if I'm just missing a hook or something, but at least it works and it can be automated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.