我无法在我的项目中插入日期。有人能否请检查我的代码以找出错误?
在我的表中——
public function up()
{
Schema::create('basic_infos', function (Blueprint $table) {
$table->id('EmpID');
$table->string('Emp_Name');
$table->date('DOB')//date of birth;
$table->timestamps();
});
}
在我的Blade文件中 -
<input type="date" name="DOB" id="date_of_birth" class="form-control datepicker form-control-md" data-bs-toggle="tooltip" title="Date of Birth">
在我的控制器中 -
public function store(Request $request)
{
$basicInfo = BasicInfo::create([
'Emp_name' => $request->Emp_name,
'DOB' => $request->DOB,
]);
}
当我点击保存按钮时,会出现错误SQLSTATE[22007]:无效的日期时间格式:1292列的不正确日期值:'2022年8月2日'。我该如何解决?