I have a site where users can update their status. Knowing the date/time they posted the status is very important. I create a field in my table and gave it the date time type.
I am new to working with dates/times. I know the structure for the datetime field is this:
YYYY-MM-DD HH:MM:SS
I thought doing this in my INSERT query would work, but It didnt.
$query= "INSERT INTO posts (user_id, story, date, view) VALUES ('$user_id', '$story',
'date()', '1')";
When I check the database table the post is successful, but the datetime reads
0000-00-00 00:00:00
What can I do to achieve my end result. This whole unix time stamp and stuff with date/time really confuses me. Thanks.
Don’t quote the mysql function, and you should use
NOW()instead ofDATE().