2013-04-18 85 views
0

我试图将缺省日期更改为Yii cjuidatepicker中上个月的第一天。 日期正确显示在文本框中,但在日期选择器弹出窗口中显示当前日期。将缺省日期更改为上个月的第一天

代码

$model_form->suspended_date_from =date("d-M-Y", mktime(0, 0, 0, date("m")-1, 1, date("Y"))); 
    $date= date('dd-MM-yy', strtotime($model_form->suspended_date_from)); 
         $this->widget('zii.widgets.jui.CJuiDatePicker', array(
          'model' => $model_form, 
          'attribute' => 'suspended_date_from', 
          'htmlOptions' => array(
           'class' => 'reporttext-field fromdate', 
           'id' => uniqid(), 
          ), 
          'options' => array(

           'dateFormat' => 'dd-MM-yy', 
           'defaultDate'=> $date, 
           // 'beforeShowDay'=>'unavailable', 


           'showAnim' => 'fade', 
           //'onSelect' => 'js:function(selectedDate) {$(".todate").datepicker("option", "minDate", selectedDate);}' 
          ), 
         )); 

我怎么能显示出它的日期选择器弹出?

回答

1

您有incorect日期格式。 dd-MM-yy(??)这个返回类似1818-AprApr-1313;所以我认为它是无效的。如果您将日期格式更改为d-M-y,那么您将拥有您想要的内容。你是否使用两种不同的日期格式? ("d-M-Y" and "d-M-y")

$date= date('d-M-y', strtotime($model_form->suspended_date_from)); 
         $this->widget('zii.widgets.jui.CJuiDatePicker', array(
          'model' => $model_form, 
          'attribute' => 'suspended_date_from', 
          'htmlOptions' => array(
           'class' => 'reporttext-field fromdate', 
           'id' => uniqid(), 
          ), 
          'options' => array(

           'dateFormat' => 'd-M-y', 
           'defaultDate'=> $date, 
           // 'beforeShowDay'=>'unavailable', 


           'showAnim' => 'fade', 
           //'onSelect' => 'js:function(selectedDate) {$(".todate").datepicker("option", "minDate", selectedDate);}' 
          ), 
         )); 

类似这样的东西适合我。

+0

Thanks..That .. – Gopesh 2013-04-19 04:45:49

相关问题