我想保存在yii2 datepicker [duplicate]中保存的不同日期格式

I am using yii2 datepicker in my project. I want to show selected date as dd/mm/YYYY but want to save date in model as YYYY-mm-dd. How can I do so?

</div>

You can format datepicker in Controller,and then render the view.

Controller:

$model->birth_date=Yii::$app->formatter->asDate($model->birth_date, "dd/mm/yyyy");

Then Store like this:

$model->birth_date=Yii::$app->formatter->asDate($model->birth_date, "yyyy-mm-dd");