在我的Ticket.php中,当我从CRUD创建一些内容时,我希望它能够获得时区中的当前时间。但我收到错误"类DateTime的对象无法转换为字符串"我在db time_start
中使用了TIMESTAMP到目前为止我已经做到了这一点:
public function actionCreate()
{
$model = new Ticket();
if ($model->load(Yii::$app->request->post()) && $model->save())
{
return $this->redirect(['view', 'id' => $model->id]);
} else {
// $employeeIDs = ArrayHelper::map(Employee::find()->all(), 'id', 'emp_name');
$my_date = new \DateTime("now", new \DateTimeZone('Asia/Manila'));
$model->time_start = $my_date;
$model->status = ('On Going');
// $model->employee_respond_id = array_rand($employeeIDs);
return $this->renderAjax('create', [
'model' => $model,
]);
}
}
答案 0 :(得分:0)
在分配给$ model-> time_start时,您应格式化$ my_date,因为这样您就可以将DateTime对象分配给基元成员。例如:
ActiveSheet.Range("$A$2:$AI$5000").AutoFilter Field:=3, Criteria1:="1"
Range(Range("C3"), Range("C3").End(xlDown)).NumberFormat = "00"
ActiveSheet.Range("$A$2:$AI$5000").AutoFilter Field:=3