Storing currentDate in database
I am using the NOW() function to store date in the databas开发者_运维百科e. But when i check the values in the database, the date is something else.
$sql="INSERT INTO feedback_comments
(posted_by, email, comments_text, comment_date)
VALUES
('$postedBy','$emailID','$message',NOW())";
Is it always off by the same amount? If so, it's likely to be either a configuration difference in times between your database and PHP environment, or even two different times if they're running on separate boxes.
The other possibility is that the type of the column you're inserting in to is not correct. In that case, you'll probably get something like 20071215235026.000000
instead of '2007-12-15 23:50:26'
.
You can use current timestamp
as the field type so with out insertion it will record the date time
精彩评论