now() date/time format in mysql

Asked

Viewed 331 times

0

$verificatempo = mysql_query("SELECT * FROM logs
WHERE horario <= now() - INTERVAL 10 MINUTE
AND ip = '$ipaddress'
ORDER BY horario desc limit 1");

I would like to know the same date and time format as the now() which was used in mysql’s source line for comparison. If possible, it can be a code itself equal.

  • time is yyyy-mm-dd hh:ii:ss? or only time (hh:ii:ss)?

  • Format "YYYY-MM-DD HH-MM-SS" if used in a string context YYYYMMDDHHMMSS format if used in a numeric context in Mysql versions before Mysql 4.1.13 YYYYMMDDHHSS.uuuuuu format if used in a numeric context in Mysql 4.1.13 and newer versions

1 answer

0

The function NOW() returns the current date and time in the time zone set as a string or number in the format YYYY-MM-DD HH: MM: DD or YYYYMMDDHHMMSS.uuuuuu.

The type returned depends on the context in which it is used.

Examples

SELECT NOW();

Upshot:

inserir a descrição da imagem aqui

SELECT NOW() - INTERVAL 10 MINUTE

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.