Hello. I'm trying to select users from database that were last active today or yesterday...but there is a problem...
When a user logs in, it stores both date and the exact time. So when i want to select user from db that logged in today or yesterday i must use the exact same form of time:
F j, Y - g:i a
But it doesn't work cause g:i a is chaning every minute.
E.g. i want to select user that last logged in yesterday and if i use:
$yesterday = date('F j, Y - g:i a', time()-86400);
It will select just users that logged in yesterday at the current time. I just need those that logged in anytime but yesterday.
Here is what i have in login.php:
$nicke=$row['username']; $lastlogdate = date("F j, Y - g:i a"); . . . $querybt = "UPDATE users SET lastlogdate='$lastlogdate' WHERE username='$nicke'"; mysql_query($querybt) or die(mysql_error());
And i tried to use this in the file where i select users that logged in today or yesterday:
$yesterday = date('F j, Y - g:i a', time()-86400); $today = date('F j, Y - g:i a'); . . . $checkpemail = mysql_query("SELECT * FROM users WHERE referer='' AND lastlogdate='$yesterday' OR lastlogdate='$today'");
As i said it will select user that logged in yesterday or today but at the current time...
I want it to select users that logged in yesterday or today no matter at what time...
I know it is possible on other ways, but i don't know how to do it.
I really hope someone will help a noob :)
Thanks for reading this!