Insert current date time in a column using Laravel

You can insert current data time in a column of database table while creating a record in Laravel using Carbon::now(); method.

Answers 1
  • Get current date and insert in a column of table using carbon in Laravel

    //Import Carbon and pass the current datetime to a specific field which you want to update or insert.
    use Carbon\Carbon;
    $date = Carbon::now();
    //You can insert above value in created_at column of users table while updating the logged is user information.
    $user = Auth::user();
    $user->updated_at = $date;
  • Back to code snippet queries related laravel