I need to save a date in a very specific format: (2013-03-09\T17:01:34.1\Z to be precise).

I also need to allow users to edit this date after it's been saved.

I want to use the Date Popup submodule of Date to allow users to enter dates. However, it doesn't seem to support custom formats. When I enable Date Popup, I see that I lose seconds granularity, and I can no longer use custom formats at all.

Is there a way to use custom formats with Date Popup? If not, is there a recommended way of adding a popup calendar to my date field in a way that will generate dates in my custom format? Does anyone know why the developer of Date made Date Popup incompatible with custom formats?

  • Unix time has a maximum granularity of i sec. Already covered here.
    – Triskelion
    Commented Mar 8, 2013 at 18:49
  • I'm not asking about tenths of seconds. One second is all the granularity I need. Date Popup's minimum supported granularity seems to be one minute. Also, Unix timestamp is not the only date storage format that Date module offers.
    – beth
    Commented Mar 8, 2013 at 18:57
  • It was the :34.1 that caused my comment. You should open an issue for this on D.O.
    – Triskelion
    Commented Mar 8, 2013 at 19:01
  • The dot is just a delimiter. The 1 represents daylight savings time (I in PHP's date format code).
    – beth
    Commented Mar 8, 2013 at 19:03

3 Answers 3


As noted in another comment, you should set "#date_format". You should however not set it in hook_form_alter(), but rather in hook_date_combo_process_alter(). Ie:

 * Implements hook_date_combo_process_alter().
 * Force 'd.m.Y' date format
function mymodule_date_combo_process_alter(&$element, &$form_state, $context) {
  $element['value']['#date_format'] = 'd.m.Y';

The popup sub-module uses the value set here, but not as-is. The thing is that the date format used by the jquery popup is different than that set in #date_format. The date_popup sub-module automatically converts the date format with the functions "date_popup_format_to_popup" and "date_popup_format_to_popup_time".

Sorry that I didn't answer your question completely. I don't have time right now to do that. But I hope you can get I gave you some insight that will help you for your specific problem. You may want to examine the functions 'date_popup_process_date_part' and 'date_popup_process_time_part' in the file 'date_popup/date_popup.module'


Drupal's Date module includes a 'Date Popup' sub-module which handles date pop-up widgets. These widgets are available in the FAPI (form api) and can be configured with custom formats via the #date_format property.

You could implement hook_form_alter() and change the #date_format property on the date field you're working with. I believe this property will support all formatting available in PHP's standard date() function.

  • When I do this in hook_form_alter() it just makes the date field's input box disappear.
    – beth
    Commented Mar 8, 2013 at 21:39
  • #date_format is a weird one, you have to have it in exactly this format if I remember rightly: Y-m-d H:i:s
    – Clive
    Commented Mar 9, 2013 at 12:50
  • If there is a particular date format required to enter anything in #date_format, what is the point of having a #date_format element?
    – beth
    Commented Mar 15, 2013 at 19:01

If you are referring to the Scheduler block options that have to be changed site-wide, the format can be set on the Scheduler settings page (http://example.com/admin/settings/scheduler)

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.