I'm using custom form for getting results from a web service.

This is a part of my form


$form['starting_date'] = array(
   '#type' => 'date_popup',
   '#title' => 'Starting date',   
   '#date_format' => 'd.m.Y',

As you can see I'm using the date_popup from the Date module.

It's displaying correct with this format d.m.Y. but after submitting the form, I've got error from a web service, because the string I'm passing . form_state['values']['starting_date'] . on print, the values are with different format.

Lets say a user selects 10.02.2014 (today), the form_state displays as 2014-10-02.

How can I fix that? The web service has to receive only with this format d.m.Y to display the results, otherwise it doesn't work.

1 Answer 1


1.Add a js file to the module and
2.In the js add the following code using the id of date field to change the date format of the date picker
3.check the link for reference

$( ".selector" ).datepicker({ dateFormat: "yy-mm-dd" });
  • Thank you for your answer, but that didn't work. There's must be something related with form_state, 'cos I can see with dpm($form_state); that the values are in different format, even I set date_format to the date_popup. Feb 10, 2014 at 21:10

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.