I'm using the following MYSQL QUERY to select all entries which are 1 minute or less old (yes I know I should be using PDO):
$result = mysql_query("SELECT customname, online FROM users WHERE online > DATE_SUB(now(), INTERVAL 1 MINUTE) ORDER BY online DESC")
or die(mysql_error());
Here is my table output:
Last Seen
2015-12-14 08:07:36
2015-12-14 08:07:36
2015-12-14 08:07:36
2015-12-14 06:50:30
2015-12-14 06:50:29
2015-12-14 05:41:16
2015-12-14 03:44:00
My issue is it's selecting times outside of the parameters I specified. The entries 2015-12-14 06:50:30, 2015-12-14 06:50:29, 2015-12-14 05:41:16, 2015-12-14 03:44:00 far exceed the one minute INTERVAL.
UPDATE:
I've tried all the suggestions below and the "duplicates" suggestions and I'm still getting the same results. The datatype for online is datetime.
If my query is:
$result = mysql_query("SELECT online FROM users WHERE online > date_sub(now(), interval 1 minute) ORDER BY online DESC")
or die(mysql_error());
then my output is:
Last Seen
2015-12-14 22:51:50 (should display)
2015-12-14 22:51:49 (should display)
2015-12-14 22:51:47 (should display)
2015-12-14 22:16:52 (shouldnt display way over a minute ago)
2015-12-14 22:14:24 (shouldnt display way over a minute ago)
2015-12-14 21:40:15 (shouldnt display way over a minute ago)
2015-12-14 21:34:34 (shouldnt display way over a minute ago)
2015-12-14 21:13:21 (shouldnt display way over a minute ago)
2015-12-14 21:07:57 (shouldnt display way over a minute ago)
2015-12-14 20:12:59 (shouldnt display way over a minute ago)
2015-12-14 19:13:53 (shouldnt display way over a minute ago)
2015-12-14 18:55:40 (shouldnt display way over a minute ago)