Cjuidatepicker

Hi Everyone,

I have made an application in which i have a analytics option, in this i have given user to choose start and end date, for date part i have use CJuiDatePicker.

When i select start and end date and click on submit button it shows result but my start and end date becomes 1/1/1970.

Don’t know why this is happening.

Please help me.

Thanks in advance

could you show us your code?

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

                            'model' => $model,


                            'name'=>'SearchForm[calendarBegin]',


                            'options'=>array(


                                    'showAnim'=>'fold',


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


                                    'defaultDate' => $model->calendarBegin ? CTimestamp::formatDate("d/m/Y", $model->calendarBegin) : CTimestamp::formatDate("d/m/Y", strtotime("now")),


                            ),


                            'htmlOptions'=>array(


                                    'style'=>'height:20px;',


                            ),


                    ));

This is my code for start date, $model->calendarBegin is the attribute for start date.

Try :



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


            'model' => $model,


            'attribut'=>'calendarBegin',


            'name' => 'SearchForm[calendarBegin]',


            'options' => array(


                'showAnim' => 'fold',


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


                'defaultDate' => $model->calendarBegin ? CTimestamp::formatDate("d/m/Y", $model->calendarBegin) : CTimestamp::formatDate("d/m/Y", strtotime("now")),


            ),


            'htmlOptions' => array(


                'style' => 'height:20px;',


            ),


        ));

PS : Are you french ?

$pattern = ‘dd/MM/yyyy’;

$timestamp = strtotime($model->calendarBegin);

if ($timestamp !== false)

$model->calendarBegin = Yii::app()->getDateFormatter()->format($pattern, $timestamp);

else

$model->calendarBegin = '';

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

'model' => $model,


'attribute'=>'calendarBegin',


'options'=>array(


	'showAnim'=>'fold',


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


),


'htmlOptions'=>array(


	'style'=>'height:20px;',


),

));

Note:

before save database, must convert date to MySQL date format

$timestamp = CDateTimeParser::parse($model->calendarBegin, ‘dd/MM/yyyy’);

if ($timestamp === false)

$model->calendarBegin = '';

else

$model->calendarBegin = date('Y-m-d', $timestamp);

Hey friends , thanks for all the replies, my problem is solved .

You people’s solutions works for me.

Thank you.

My own problem is that, Cjuidatepicker returns null value in my form. After submission, nothing is stored in the db, thus the output would be 0000:00:00. Can someone help please. This is my code:

<?php //echo $form->dateField($model,'date');


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


'model'=>$model,


'name'=>'date',





'attribute'=>'date',


// additional javascript options for the date picker plugin


'options'=>array(


    'showAnim'=>'fold',


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


),


'htmlOptions'=>array(


    'style'=>'height:20px;'


),

));

	 ?>