I want return the number of dates which have a difference less than 30 minutes. These are the records stored in the database:
id | last_login
0 2019-02-11 17:22:47
1 0000-00-00 00:00:00
2 2019-02-11 17:22:03
3 0000-00-00 00:00:00
4 0000-00-00 00:00:00
the result of the query should be 2, but I get 1:
$time = strtotime('+30 minutes');
return $this->db->select('COUNT(last_login) AS users_online')
->from('login')
->where('UNIX_TIMESTAMP(last_login) < ' . $time)
->get()->num_rows();