Yii2 View DateTime Format (d-m-Y H:i:s) But When Save/update in DB Change format to Y-m-d H:i:s

后端 未结 5 1531
礼貌的吻别
礼貌的吻别 2021-02-06 04:26

I\'m Using Kartik DateTimePicker Extension

field($model, \'Created\')->widget(DateTimePicker::classname(),[
        \'model\' => $model,
          


        
5条回答
  •  余生分开走
    2021-02-06 05:11

    use in active form

    'clientOptions' => ['alias' => 'dd-mm-yyyy'],

    use in active form

    echo MaskedInput::widget([
    'name' => 'input-31',
    'clientOptions' => ['alias' =>  'date']]);
    

    use class

    Class yii\widgets\MaskedInput

    Example

    field($model, 'date_of_birth')->widget(\yii\widgets\MaskedInput::className(), [
        'name' => 'input-31',
        'clientOptions' => ['alias' =>  'dd-mm-yyyy'],        ]) ?>   
    

提交回复
热议问题