Results 1 to 5 of 5

Thread: Login time/expire

  1. #1

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    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


    Has someone helped you? Then you can Rate their helpful post.

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Login time/expire

    I don't believe there is a Now() function in PHP. Use Time() instead. HTH

  3. #3

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    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?


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    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

  5. #5

    Thread Starter
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Login time/expire

    That could work I'll try Thanks!


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width