how to calcualte loin and logout time?

Discussion in 'PHP' started by ststacytucker9, May 7, 2010.

  1. #1
    Hi All,

    Anyone can please tell me how to calculate login and logout time(date:hours:minutes:second) in php pages, Please give me coding of it, we would be appreciated your kid of help.
     
    ststacytucker9, May 7, 2010 IP
  2. live.co.uk

    live.co.uk Banned

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you want get for you
    or for visitor?
     
    live.co.uk, May 7, 2010 IP
  3. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    this would actually work only if user perform the logout operation. I know no way to do this, if the user simply closes the browser.

    One way of doing this, providing user are using login and logout functions, is to keep track of time and IP of the user while login and then by difference by logout.
    This is what google analytics is doing to calculate the bouncing rate, and the time spent browsing the site. keeping track of IP while the user travels through the pages of the site, but losing almost all the time, track of the last action. Browser does not notify the server when it is closing.
     
    webrickco, May 7, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    1. Use SUM mysql statement for hours and minutes fields.
    2. Change minutes to hours (/60) and keep the remainder as minutes (%60).
    3. Collate time elements and labels for output.
     
    roopajyothi, May 7, 2010 IP
  5. ststacytucker9

    ststacytucker9 Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for Suggestion
     
    ststacytucker9, May 12, 2010 IP
  6. abstractworld

    abstractworld Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can either have a user activity table. As user logs in get the time in php time(); (check reference for formatting) and put this time in db...similarly as user logsout get the time and put in db,,,you can put it out of db and calculate the difference anytime.
    You can also play with cookies or sessions to keep track of time.
    Problems will be in case when user does not press logout. To get this done you can update the db or cookie for logout as current time....so whatever the last activity of the user be, you can get the time difference from last activity to login...

    Hope this helps.
    Thanks.
     
    abstractworld, May 12, 2010 IP