I'm doing a query to the database and I want to show me only the records in which the difference between the query time (NOW())
and the time of the datetime variable is less than 60 minutes ... (which shows everything that is more than one hour away from the current time)
Looking at the manual I have arrived at this query ... but it is not filtering it:
PHP Script:
$consulta = "SELECT tipo,nombre,descripcion,formatoFecha FROM ".$tabla." WHERE TIMESTAMPDIFF(MINUTE,formatoFecha,NOW()) >60 ORDER BY TIMESTAMPDIFF(MINUTE,formatoFecha,NOW()) DESC";
$resultado= mysqli_query($link,$consulta);
echo of the query:
SELECT tipo,nombre,descripcion,formatoFecha FROM servicio WHERE TIMESTAMPDIFF(MINUTE,formatoFecha,NOW()) <60 ORDER BY TIMESTAMPDIFF(MINUTE,formatoFecha,NOW()) DESC;
The value of all fields Datedate (variable datetime) is greater than the current date except for one, whose value is 2017-02-24 04:19:00 value that is 60 minutes lower than the time at which I write the question 2017-02-24 03:44:00
What am I doing wrong?
PS: I've tried 60
I complete the post:
putenv('TZ=Europe/Madrid'); //hora de españa
and I added this echo to debug:
echo $diferencia = TIMESTAMPDIFF(MINUTE,'2017-02-24 03:19:00',NOW());
whose result is:
Fatal error</b>: Call to undefined function TIMESTAMPDIFF()
also this echo:
echo $hora = NOW();
with this result:
Fatal error</b>: Call to undefined function NOW()
I think there is no function in the hosting that I use, which is hostinger just in case