1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to calcualte loin and logout time?

Discussion in 'PHP' started by myautoagent, Apr 22, 2010.

  1. #1
    Hi All,
    SEMrush
    please let us know how to calculate login and logout time(date:hours:minutes:second) in php pages, please give me coding its, we would be appreciated your kind of help.
     
    myautoagent, Apr 22, 2010 IP
    SEMrush
  2. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #2
    Are you storing the login/logout time for users in your db? Or do you mean entry/exit times?
     
    mfscripts, Apr 22, 2010 IP
  3. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #3
    What details are you storing in the login information, and how are you storing it?

    There are many ways you can do this, but at lot of it depends on what you are doing at the moment.
     
    lukeg32, Apr 22, 2010 IP
  4. myautoagent

    myautoagent Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for quick reply, I have store time in login and logout (date:hours:minutes:second)
    our codding as
     
    myautoagent, Apr 22, 2010 IP
  5. devidhood

    devidhood Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    hiiiiiiiii

    u can find login and logout time using session variable.for more details u can go to the website w3schools or php.net

    i hope this will help u.

    thanks

    Regards

    devid
     
    devidhood, Apr 22, 2010 IP
  6. myautoagent

    myautoagent Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I have calculated login and logout time, but we need difference between both time or logout subtract login time.
     
    myautoagent, Apr 22, 2010 IP
  7. lukeg32

    lukeg32 Peon

    Messages:
    645
    Likes Received:
    19
    Best Answers:
    1
    Trophy Points:
    0
    #7
    As you are storing the login time in a database, you can do this quite simply in a single select using the mysql date/time functions.

    SELECT TIMEDIFF(logout, login);
    Will give you the number of hours/minutes/seconds between the two. It will not count days.

    E.G (you should get the login time from your stored value)

    SELECT TIMEDIFF(now(), '2010-04-20 14:12:23');
    PHP:
    OUTPUT: 48:40:58

    Its not too hard to represent the number of days, if needed either. Check the SQL time/date functions.
     
    lukeg32, Apr 22, 2010 IP