I have used sql's now()
function several times in normal query in php db connectivity...
But in laravel it does not displays anything and also the data is not inserted
the code I am using is:
$exercise = Exercise::insert(
array( 'fk_users_id' => '1',
'fk_equipments_id' => $equipment,
'muscular_group' => $muscular,
'exercise_name' => $postedContent['exercise_name'],
'exercise_type' => $postedContent['type'],
'Status' => '1',
'DateCreated' => 'NOW( )',
'DateModified' => 'NOW( )')
);
it stores the data into the database but the time in not stored in any of the columns
at first my method was:
$exerciseDetails = Input::all();
$exercise = Exercise::create($exerciseDetails);
the above method updates date and time itself and worked fine for other controllers but now I am having a problem of having a check box checked array in my post so it throws error
is there any other method in laravel to do this ??
Laravel comes with created_at and updated_at timestamp fields by default, which it keeps updated by itself.
$now = DB::raw('NOW()');
$now variable can use in insert like
$user = new User;
$user->name = $name;
$user->created_at = $now;
You could be looking to direct query to get MySQL DB current Time.
You can go like this;
$currentDBtime = DB::select( 'select NOW() as the_time' );
$currentDBtime[0]->the_time;