使用Yii2中的模型值设置日期函数

Hi i have function where i need to take values from dropdownlist(in 3 dropdownlists i have year, month, day like in facebook registration). I want to set date from this 3 values.

public function setDate()
{
   $month=$this->month+1;
   $date = date_create();
   date_date_set($date, $this->year,$month, $this->day);
   return date_format($date, 'Y-m-d');

}

then in my controller i want to save my date but it doesnt work.

 if ($model->load(Yii::$app->request->post()) && $model->validate()) {
        $model->setDate();
        $model->save();

Which method of date can i use to this operation where i can give my values in parameters?

i try this method too

public function setDate()
{
   $month=$this->month+1;
   $date = new DateTime();
   $date ->setDate($this->year,$month, $this->day);
   return $date->format('Y-m-d');

}

but i have

Argument 1 passed to Faker\Provider\Base::__construct() must be an instance of Faker\Generator, none given, called in E:\htdocs\mesport\frontend\modules\settings\models\Profile.php on line 119 and defined

In your custom method you actually don't change the model attribute value. Assuming this method is located inside model, replace return line by:

$this->yourDateAttribute = ...;

Also make sure this attribute is safe in current scenario.