あなたは前ので、あなたの問題は、あなたが例えばを必要とする値を割り当てるためのPHPのfunctinを使用してcontrollerActionに管理することができ
..レンダリング呼び出して、あなたのコントローラに直接$モデル - >時間_に値を割り当てることができます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,
]);
}
}
たり、特定のタイムゾーンが必要な場合
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,
]);
}
}
PH PはあなたのPCではなくサーバ上で動作します。それはあなたが別のことを話さない限り、サーバー時間を使用します。あなたは、PCからPHPスクリプトに時間を送る必要があります。それは、 '日付ピッカー'で使用する時間を使用することができます –