insert current date time using laravel
use laravel helper function
now()
other wise used carbon
class
Carbon\Carbon::now()
used like that
$data = array("name" => $name,"address" => $address,"created_at"=> Carbon::now(),"updated_at"=> now());
DB::table('student')->insert($data);
for more information see
use have also use this get to current date time time its work.
$current_date = date('Y-m-d H:i:s');
And also i have update and set in your function you have to put this.
function insert(Request $req)
{
$name=$req->input('name');
$address=$req->input('address');
$current_date_time = date('Y-m-d H:i:s');
$data=array("name" => $name,"address" => $address,"created_at"=>
$current_date_time,"updated_at"=>$current_date_time);
DB::table('student')->insert($data);
echo "Record inserted successfully.<br/>";
return redirect('/');
}