'yyyy-MM-dd HH:mm:ss' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm:ss' ,'timeZone' => 'UTC' ], /*enable only minutes*/ // [[ 'end' , ], 'date' ,'format' => 'yyyy-MM-dd HH:mm' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm' ,'timeZone' => 'UTC' ], [[ 'end' ], 'validateEndDate' ] ]; } public function validateEndDate($attribute,$params){ if ( isset($this->lastCollection)){ if ( strtotime( $this->lastCollection->end ) >= strtotime( $this->timestampEnd ) ){ $this->addError($attribute,Yii::t('frontend/collection' ,'End date is invalid') ); } } } public function beforeSave($insert){ if (parent::beforeSave($insert)) { $this->id_user = Yii::$app->user->id; $this->created_by = Yii::$app->user->id; $paidAt = Transfer::mkPaidAtTotals($this->timestampStart, $this->timestampEnd, $this->user->id, null, $this->account->id_account, $this->accounts ); $this->money = $paidAt['total']; return true; } else { return false; } } }