-
Login time/expire
To keep track of the time a user logs in I created a field in the DB called LoginTime (Type : timestamp(10)). So when someone logs in, I use this :
PHP Code:
$sql = "UPDATE `users` SET `LoginTime`=NOW() WHERE `ID`=$id LIMIT 1 ;";
to set the time. Then, if I want to compare the time now with the time logged in, I get an error here :
PHP Code:
if ($row['LoginTime']+15 < NOW()){
So instead of NOW(), can I use time? Or maybe somehow format time to compare the two?
Thanks :)
-
Re: Login time/expire
I don't believe there is a Now() function in PHP. Use Time() instead. HTH :)
-
Re: Login time/expire
I figured... But how can I format the Time() function to be able to compare it to the NOW() from the MySQL query?
-
Re: Login time/expire
why dont you only select the dates that are before/after a certain time?
Code:
SELECT * from table WHERE DATE_SUB(now(), interval 5 minute) >= time
-
Re: Login time/expire
That could work :) I'll try :) Thanks!