yddib Posted September 12, 2008 Share Posted September 12, 2008 I have comments being posted into the database. Is there a way to get today's date into the database automatically? Quote Link to comment https://forums.phpfreaks.com/topic/123898-solved-date-into-database/ Share on other sites More sharing options...
dropfaith Posted September 12, 2008 Share Posted September 12, 2008 i like to display the date to user before its inserted in case they want to backdate something and use the code below in the value of a form <?php $today = date("F j, Y"); PRINT "$today"; ?> but this might help too http://www.tizag.com/mysqlTutorial/mysql-date.php Quote Link to comment https://forums.phpfreaks.com/topic/123898-solved-date-into-database/#findComment-639617 Share on other sites More sharing options...
yddib Posted September 15, 2008 Author Share Posted September 15, 2008 That didn't work. Blank screen!! Quote Link to comment https://forums.phpfreaks.com/topic/123898-solved-date-into-database/#findComment-641825 Share on other sites More sharing options...
JasonLewis Posted September 15, 2008 Share Posted September 15, 2008 When inserting the comment use MySQL's NOW() function on the field, but make sure it is a DATETIME or DATE type. $query = mysql_query("INSERT INTO comments (date) VALUES (now())") or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/123898-solved-date-into-database/#findComment-641828 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.