CJuidatepicker with altForm

so my database field is of type date which is: yy-mm-dd

The code down below is working fine, for yy-mm-dd how ever I want to display the date to the user as mm-dd-yy but insert into the database as yy-mm-dd.

I’ve been trying to use altFormat, and it seems to not work. There really isn’t much documentation about it in CJUI date picker. I also try to set defaultOptions =>array(‘altFormat’ => ‘mm-dd-yy’) but its not working.


	&#036;this-&gt;widget('zii.widgets.jui.CJuiDatePicker', array(

    'name' =&gt; CHtml::activeName(&#036;model, 'date'),


    'attribute' =&gt; 'date',

    'value' =&gt; &#036;model-&gt;attributes['date'],



            'dateFormat' =&gt; 'yy-mm-dd',







any luck with this anyone? using altFormat with CJUI

Hi, Chief

I haven’t tested, but I’m afraid you are probably missing the “altField” option that should be used with “altFormat” option.

Hi softark,

Do you happen to know how to use it?

Sorry, I haven’t tried “altField” in my projects, because I always use ‘yy-mm-dd’ in my UIs.

Check the following


And, I think the other approach might be worth considering …

What about converting the date format on the server side? I mean

  1. after loading … yy-mm-dd => mm-dd-yy

  2. before saving … mm-dd-yy => yy-mm-dd

yeah thats what I ended up doing. I just converted it on the php side.

how did you do this?

with beforeSave and afterFind methods in your model.