I'am building comments managment system and i need to store in mysql database current comment time and date on submit. Please help me to solve this.
get the date from php server and use that in an INSERT/UPDATE command; call date ('r', time()) and insert as field value. OR, let the sql server insert the current date time: ", NOW()," as field value
Yeah rene7705 is right, all you have to do is something like below... <? $date = date("F j, Y, g:i a"); $whatever =mysql_query("INSERT INTO `table_name` (`id` , `date`) VALUES ('', '$date')"); ==================================== Or to update a table just do this.. ==================================== $date = date("F j, Y, g:i a"); $whatever =mysql_query("UPDATE `table_name` SET `date` = '".$date." WHERE `id` ='$id'"); ?> PHP: This would insert the date like this: March 10, 2001, 5:16 pm Hope it helps...
It would be more practical to save the date as a timestamp. This would make it easier to output the date in various formats.
Hi, I am not quite sure how to use NOW(). So just need to enter NOW() as the default value filed in table in mysql?