Adding Days To Current Date Value

How can I add days in CJuiDatePicker? I want to store default value = current date + 7days.

This is my code but it only display date today.




$this->beginWidget('zii.widgets.jui.CJuiDatePicker', array(

						'id'=>'date_opening',

						'model'=>$model,

						'attribute'=>'date_opening',

						'name'=>'date_opening',

						'htmlOptions'=>array('required'=>'required', 'value'=>date('m/d/y')),

					)); 

					$this->endWidget();



Thank you :)

‘value’, or ‘defaultValue’, goes in the ‘options’=>array() param for JuiDatePicker not in the htmlOptions. If you look at the source code in the browser you probably see “value”=“05/09/20014” in one of html tags involved with the widget.

Suggestion:




$date = new DateTime(); // Todays date

 $interval = new DateInterval('P7D'); // Periode of 7 days

 $date->add($interval); // $date is not 7 days ahead



Put $date->format(‘Y-m-d’) into your code:


$this->beginWidget('zii.widgets.jui.CJuiDatePicker', array(

                                                'id'=>'date_opening',

                                                'model'=>$model,

                                                'attribute'=>'date_opening',

                                             	'name'=>'date_opening',

                                                'value'=>$date->format('Y-m-d'),

                                                'htmlOptions'=>array('required'=>'required', 'value'=>date('m/d/y')),

                                        )); 

Thank you. I didn’t notice it at first. I would move it to option param :)

This works for me. Thank you. :)