我正在尝试创建一个查询来获取过去 20 分钟内看到的用户,但它没有获取正确的结果。“last_seen”行包含用户上次加载页面的时间戳。
mysql_query ("SELECT user,rank,ipaddress FROM
" . SQL_PREFIX . "site_session
WHERE last_seen > ".strtotime("-30 minutes")." order by user desc");
尝试:
mysql_query ("SELECT user,rank,ipaddress FROM " . SQL_PREFIX . "site_session WHERE last_seen > (NOW() - INTERVAL 20 MINUTE) order by user desc");
尝试这个:
SELECT user,rank,ipaddress
FROM " . SQL_PREFIX . "site_session
WHERE last_seen > INTERVAL CURRENT_TIMESTAMP - 20 MINUTE
order by user desc
尝试这个
mysql_query ("SELECT user,rank,ipaddress FROM " . SQL_PREFIX . "site_session WHERE last_seen > ".time()-1200." order by user desc");
time() 是一个 php 函数,而不是 mysql