You can assign the value to $model->time_start directly in your controller before call the render ..
so you problem can be managed in controllerAction using php functin for assign the value you need eg in actionCreate
public function actionCreate()
{
$model = new MyModel();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
// assign the the date and time of the server that the code runs on.
$model->time_start = date("d-m-Y H:i:s");
return $this->render('create', [
'model' => $model,
]);
}
}
or if you need an specific timezone
public function actionCreate()
{
$model = new MyModel();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
// assign the the date and time of the server that the code runs on.
//
$my_date = new DateTime("now", new DateTimeZone('America/New_York') );
$model->time_start = $my_date;
return $this->render('create', [
'model' => $model,
]);
}
}