matthew798 Posted September 9, 2008 Share Posted September 9, 2008 hey guys. I am trying to get the date to be stored in an MYSQL databse. But it executes a mathematical equation each time and return the answer instead of the date LOL! I explain... $date = date("m-d-y"); mysql_query("INSERT INTO news (title, body, date) VALUES('Timmy Mellowman', '23', $date ) ") or die(mysql_error()); I always get 0.125000000000000000 as the date! I tried with "-" but then it gives me -8 lol.... I know, this is stupid but i just can't figure it out and i dont wanna have to separate it with a letter or sumthing... Link to comment https://forums.phpfreaks.com/topic/123380-date-into-database/ Share on other sites More sharing options...
The Little Guy Posted September 9, 2008 Share Posted September 9, 2008 Try this: $date = date("m-d-y"); mysql_query("INSERT INTO news (`title`, `body`, `date`) VALUES('Timmy Mellowman', '23', '$date' ) ") or die(mysql_error()); What input type did you set date to? Link to comment https://forums.phpfreaks.com/topic/123380-date-into-database/#findComment-637268 Share on other sites More sharing options...
JasonLewis Posted September 9, 2008 Share Posted September 9, 2008 If the field is DATE or DATETIME then just use the MySQL function now(). mysql_query("INSERT INTO news (`title`, `body`, `date`) VALUES ('Timmy Mellowman', '23', now())") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/123380-date-into-database/#findComment-637295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.