CJuiDateTimePicker: Only show a range of time

I need my CJuiDateTimePicker to only show a range of time because it would help me in a client validation. The thing is:

I have this two variables: $contract->init_date and $contract->years_valid.

I need to create a new object that has contract_id as an attribute. I can’t create it if it’s out of range. In the form, I need to be able to show the CJuiDateTimePicker only showing the date of validity of the contract.

As example: if $contract->init_date = ‘2008-03-12’ and $contract->years_valid = 5, then the timepicker needs to show only dates from 2008-03-12 to 2013-03-12’.

Would it be particullarly difficult to do that. I’ve read a lot and I don’t find a solution to this.

Thanks a lot

Which CJuiDateTimePicker is this?

I don’t know, but it might be possible to add minDate/maxDate to the options attribute (CJuiDatePicker).

Example of jui datepicker reference

Yeah, you’re right. My bad. I was talking about CJuiDatePicker. I’ll try what you just said. By the moment I wrote this post I was too tired of coding. And my brain was tired. Sorry. And thanks for answering

I solved my problem. Thanks so much for your help. It’s funny but I wasn’t looking on http://api.jqueryui.com/. I didn’t know I could use that. I’m still a student. Although, aren’t all of us? haha

Anyway thanks again, I’m sharing the code of my datepicker:

<?php $this->widget(‘zii.widgets.jui.CJuiDatePicker’, array(

                    'language' =&gt; 'es',


                    'options' =&gt; array(


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


                        'constrainInput' =&gt; 'false',


                        'minDate' =&gt; &#036;contract-init_date


                        'maxDate' =&gt; date(&quot;Y-m-d&quot;,strtotime(&#036;contract-init_date+'.&#036;contract-&gt;years_valid.' years')),


                        'showAnim' =&gt; 'fade'),


                    'model' =&gt; &#036;model,


                    'attribute' =&gt; 'shop_order',


                    'htmlOptions' =&gt; array('class' =&gt; 'form-control',


                       ),


                ));?&gt;

you could add ‘changeYear’=>true,

           'changeMonth'=&gt;true,