When I try to run the following query:
... WHERE `date` = DATE_ADD(NOW(), INTERVAL 10 HOUR)
It doesn’t work, so I have to use the $date = date("Y-m-d", strtotime('+10 hours'))
But why date_add doesn’t work?
Thanks much
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.
Note that
DATE_ADD()function returns a time part in addition to the date. This is not the same as using php’sdate("Y-m-d", strtotime('+10 hours')), which only returns the date part.You could use
WHERE date = DATE(DATE_ADD(NOW(), INTERVAL 10 HOUR))instead:Test case: