Error running insert with NOW()

I have been trying to run the following query:

$user = new Users(); $user->save( [ "name" => $name, "created_at" => NOW(), ] );

When executed I get the following error: Call to undefined function NOW() please can anyone advise.


NOW() is a MySQL function, that's why you are getting the PHP error. Use time() or follow @corentin-begne link :)

$user->save( [ "name" => $name, "created_at" => time() ] );