i have a table that looks like this:
Field: msg_sent_datetime
Type: datetime
yet when i use NOW() in a php mysql insert query it is staying as all zeros?
any idea why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using it only at the time of
INSERT, you could make the field aTIMESTAMPand set a default ofCURRENT_TIMESTAMP.Without knowing more about the code it’s difficult to suggest much else.
Example with
CURRENT_TIMESTAMPAlso, if you want it to always update when there’s a change to the row, you can add the
ON UPDATE CURRENT_TIMESTAMPproperty to the table definition:Of course, all of this is totally dependent on switching to
TIMESTAMPwhich you may not want