1

Im using a JQuery DatePicker in a Zend Framework based application Form. Here is the code for the date picker

$this->addElement('datePicker','movie_release_date', array(
            'label' => 'Release Date:',
            'required'=> false
            )
    );

By default, when you pick the date, it is stored in the text input like 'mm/dd/yyyy'

But I want to have it like 'yyyy-mm-dd'

I tried many options like dateFormat, format, etc, within the addElement method, but nothing worked!

Please help! Im stuck and couldn't find anything about that on the forums....

4 Answers 4

3

Ok I finally found how to do it:

$element = new ZendX_JQuery_Form_Element_DatePicker('dp1',
            array('jQueryParams' => array('dateFormat' => 'yy-mm-dd'))
        );
$this->addElement($element);

That's it! Thanks for your help.

Sign up to request clarification or add additional context in comments.

Comments

1

Try adding this to your array:

'dateFormat' => 'yy-mm-dd',

If you're still having trouble, see if you can upgrade to the most recent version of the control from jQuery UI's site. Here is usage documentation for date formats: http://jqueryui.com/demos/datepicker/#date-formats

1 Comment

As I said in my question: "I tried many options like dateFormat, format, etc, within the addElement method, but nothing worked!" I already have the last version of JQuery UI... And the link you sent explains how to change the format within a JQuery call in a page, not in a Zend form.
0

First use Zend_Locale to set up date format, then with ZendX_JQuery:

$picker = new ZendX_JQuery_View_Helper_DatePicker();
$picker->resolveZendLocaleToDatePickerFormat();

1 Comment

Ok, looks good! But how do I add this element to the form then? How do I create my ZendX_JQuery_Form_Element_DatePicker from this? Could you post the code from date picker creation to form element add please?
0

Be aware that safari does not recognise the format YYYY-MM-DD

Invalid date in safari

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.