Welcome Guest, Not a member yet? Register   Sign In
How do I add the date with active records, meaning a MySQL NOW() function equivalent?
#1

[eluser]gunnarflax[/eluser]
The title says it all. I tried inserting 'NOW()' as a string but it didn't work so I guess I have insert the date myself in a fitting datetime format. How do I do this?
#2

[eluser]flaky[/eluser]
Code:
$this->db->set('test', 'NOW()', false);        
$this->db->insert('test', $data);
#3

[eluser]InsiteFX[/eluser]
You can also do it like this:
Code:
$now = date("Y-m-d H:i:s");

$data = array(
    'your_date_field_name' => $now
);

$this->db->insert('your_table_name', $data);

InsiteFX
#4

[eluser]gunnarflax[/eluser]
Thanks guys! It worked perfectly (both solutions)!




Theme © iAndrew 2016 - Forum software by © MyBB