I have a field of type date in MySQL. When I try to insert any date in this field with PHP using following query, It stores 0000-00-00 in that field.
For example:
UPDATE test SET dob=2000-09-20 WHERE id=3
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.
Just quote the date.
In your query
... 2000-09-20 ...will be interpreted as a mathematical expression. The result is a number, 1971. In the date time field, a number will be zerofilled to a 6, 8, 12 or 14-digit number, so 1971 will become 001971. This number is then interpreted as YYMMDD format, so it means “year 00 month 19 day 71”, which is invalid. So the special value0000-00-00is stored.