JackJack Posted April 19, 2006 Share Posted April 19, 2006 When i insert a new table in mysql i put the date as $date.[code]mysql_query("INSERT INTO `company_news` (date, sender, title, message, company)VALUES ('$date', 'Updater', 'Company Name Updated', 'Your companys name has been updated to $name.', '$name')");[/code] When i look at what has been added the date is always "0000-00-00 00:00:00".Please helpJJ Link to comment https://forums.phpfreaks.com/topic/7826-date-and-time/ Share on other sites More sharing options...
wisewood Posted April 19, 2006 Share Posted April 19, 2006 instead of using $date as the value to insert, use NOW().This will generate a properly formatted date/time stamp for you...or at least it does with my setup.[code]mysql_query("INSERT INTO `company_news` (date, sender, title, message, company)VALUES ('NOW()', 'Updater', 'Company Name Updated', 'Your companys name has been updated to $name.', '$name')");[/code] Link to comment https://forums.phpfreaks.com/topic/7826-date-and-time/#findComment-28511 Share on other sites More sharing options...
reaper7861 Posted April 19, 2006 Share Posted April 19, 2006 also what is your declaration for date $date=? cause you can also declare it look here [a href=\"http://us3.php.net/manual/en/ref.datetime.php\" target=\"_blank\"]http://us3.php.net/manual/en/ref.datetime.php[/a]or[a href=\"http://us3.php.net/manual/en/function.date.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.date.php[/a]hope that helps, have a good day.GCT Link to comment https://forums.phpfreaks.com/topic/7826-date-and-time/#findComment-28521 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.