Welcome Guest, Not a member yet? Register   Sign In
Inserting Dates Problem in MySQL
#1

[eluser]Unknown[/eluser]
Code:
$this->db->set('date-last-updated', unix_to_human(time(), TRUE, 'eu'));
$this->db->set('date-created', unix_to_human(time(), TRUE, 'eu'));  
$this->db->insert('posts');


it just shows error....it seems like a very small mistake that causes this error but i cannot find it...

the 'date-last-updated' and 'date-created' is a DATETIME type in MySQL...

can anybody point out my mistake...

it tells me that:
Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-last-updated, date-created) VALUES ('asd', 'asd', 'asd', 'asd', '2008-01-08 21:' at line 1

any help would be appreciated....
#2

[eluser]tonanbarbarian[/eluser]
try this instead
Code:
$this->db->set('date-last-updated', date('Y-m-d H:i:s'));
$this->db->set('date-created', date('Y-m-d H:i:s'));  
$this->db->insert('posts');
MySQL prefers the date in that format. the unix_to_human will not always give that format




Theme © iAndrew 2016 - Forum software by © MyBB