date_format()期望参数1为DateTimeInterface,给定boolean

时间:2018-11-10 08:40:27

标签: php laravel-5

我通过在表单上添加日期来制作CRUD laravel,但控制器中出现错误,并且控制器中的内容也出现错误:

public function update(Request $request, $id)
{
    $suratmasuk= \App\SuratMasuk::find($id);
    $suratmasuk->no_surat=$request->get('no_surat');
    $suratmasuk->no_agenda=$request->get('no_agenda');
    $tgl_surat=date_create($request->get('tgl_surat'));``
    $format = date_format($tgl_surat,"Y-m-d");
    $suratmasuk->tgl_surat = strtotime($format);
    $tgl_terima=date_create($request->get('tgl_terima'));
    $format = date_format($tgl_terima,"Y-m-d");
    $suratmasuk->tgl_terima = strtotime($format);
    $suratmasuk->sumber_surat=$request->get('sumber_surat');
    $suratmasuk->perihal=$request->get('perihal');
    $suratmasuk->keterangan=$request->get('keterangan');
    $suratmasuk->save();
    return redirect('surat-masuk');

}

1 个答案:

答案 0 :(得分:0)

$stamp= time();
$daystotal = date("Y-m-d h:i:s",$stamp);
$postdate =  date_create(date_create_from_format('Y-m-d',$daystotal))
echo date_format($daystotal,"j M,y H:i");

输出:“ j M,y H:i