2013-04-18 53 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

相關問題