I'm currently writing a script for voting, and I need to know if the user voted in the last 5 minutes. If yes, next vote is forbidden.

How can I make a request for this?

This was my try:

WHERE time AFTER INTERVAL(CURRENT_TIMESTAMP - 5 MINUTES)
有帮助吗?

解决方案

WHERE time > NOW() - INTERVAL 5 MINUTE

Try that.

其他提示

SELECT COUNT(id), from_unixtime(`timestamp` / 1000, '%Y-%m-%d %H:%i')
FROM `table`
WHERE `timestamp` >= unix_timestamp(CURRENT_TIMESTAMP - INTERVAL 5 MINUTE) * 1000

Refer link below

Already in stackoverflow

This will work.

time < DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 5 MINUTE)

Try this:

$time = date('YmdHis', strtotime('-5 minutes', strtotime('now')));
"...WHERE time > '$time'"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top