I have a problem with a rebellious date. It turns out that I have to make a query between two dates, which would be this:
SELECT id FROM 'Pedidos' WHERE ('fecha_cobro' BETWEEN '$fechini' AND '$fechafin') AND borrado = 0
I come from a form that I select the dates that I want to appear in the search. And I convert the date from Spanish to American format so that mysql understands them and I do it like this:
But it turns out that $ date has a life of its own and only works in certain cases, for example if I put 01/01/2018, but if I put today's date it says that your aunt. I have tried to put single quotes, double quotes, magic quotes, call one of quotation marks to see if he knows anything. But nothing I can not see the error. On the other hand, if I put the date directly in the query, it always works, so I deduce that the ruling is in date.
On the other hand, I have tried to show that it brings that post in case the error was in the form, but no, it brings the correct date (in Spanish format).
Apart from going to throw a shoe Rajoy what do you think I could do?
Thank you very much for your help.