Skip to content

Instantly share code, notes, and snippets.

@cmaas
Created January 29, 2015 15:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmaas/2599f3853cea5daebaa5 to your computer and use it in GitHub Desktop.
Save cmaas/2599f3853cea5daebaa5 to your computer and use it in GitHub Desktop.
Laravel 4 – Update MySQL DATETIME field and increase value with DATE_ADD

Update MySQL DATETIME field and increase value with DATE_ADD

You can update a MySQL DATETIME field in Laravel with Eloquent like so:

DB::table('users')
    ->where('id', $user_id)
    ->update(array('valid_until' => DB::raw('DATE_ADD(valid_until, INTERVAL 1 MONTH)')));

The key is to use DB::raw().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment