Php Laravel插入日期从1日到30日
我尝试在自定义表中插入数据Php Laravel插入日期从1日到30日,php,laravel-5,Php,Laravel 5,我尝试在自定义表中插入数据 $month = date('m'); $year = date('y'); $number = cal_days_in_month(CAL_GREGORIAN, $month, $year); for ($i = 0; $i < $number; $i++) { $test = new Test(); $test->cuid = $user->id; $test->name = $user->name;
$month = date('m');
$year = date('y');
$number = cal_days_in_month(CAL_GREGORIAN, $month, $year);
for ($i = 0; $i < $number; $i++) {
$test = new Test();
$test->cuid = $user->id;
$test->name = $user->name;
$test->month = date('m');
$test->created_at = '2018-04-'+$i;
$test->save();
}
$month=日期('m');
$year=日期('y');
$number=cal_天数(cal_GREGORIAN,$month,$year);
对于($i=0;$i<$number;$i++){
$test=新测试();
$test->cuid=$user->id;
$test->name=$user->name;
$test->month=日期('m');
$test->created_at='2018-04-'+$i;
$test->save();
}
我尝试在一个月内插入数字记录
假设4月有30天,我尝试将其插入工作正常,但在创建的_at字段中,我需要插入2018-04-01至2018-04-30,但这是仅插入当前日期,以便我在上面尝试但不工作您需要将时间戳设为false
$test->timestamps=false
不,实际上我需要在created_atyes中插入从1到30的日期,并确保created_at
不会自动设置为今天
您需要设置标志$test->timestamps=false
,然后将created_设置为
是否正确,但我需要添加false仅右键正确,添加$test->timestamps=false
beforesave()
方法