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? 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 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!! 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()); Link to comment https://forums.phpfreaks.com/topic/123898-solved-date-into-database/#findComment-641828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.