问题描述
我在基于 Zend 框架的应用程序表单中使用 JQuery DatePicker.这是日期选择器的代码
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
)
);
默认情况下,当您选择日期时,它会存储在文本输入中,例如 'mm/dd/yyyy'
By default, when you pick the date, it is stored in the text input like 'mm/dd/yyyy'
但我想要它像'yyyy-mm-dd'
But I want to have it like 'yyyy-mm-dd'
我在 addElement 方法中尝试了许多选项,例如 dateFormat、format 等,但没有任何效果!
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....
推荐答案
好吧,我终于找到了方法:
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.
这篇关于Zend Framework - JQuery - 日期选择器 - 将日期格式化为 YYYY-mm-dd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!