1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

session login and logout time

Discussion in 'PHP' started by divinequran, Oct 30, 2010.

  1. divinequran

    divinequran New Member

    Joined:
    Oct 9, 2008
    Messages:
    62
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Home Page:
    Hi,

    I have to calculate login and logout time of an user. I store the session creation and session out time. How do I calculate the minutes or hours user have loged in. Do u have any code snippet for it?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    What is the time storing unit. Is it unix time stamp?

    Try this.
    Code:
    $beginTimeConverted=strtotime($beginTime);
    $endTimeConverted=strtotime($endTime);
    
    // perform subtraction
    $timeDiff=$endTimeConverted-$beginTimeConverted;
     
  3. divinequran

    divinequran New Member

    Joined:
    Oct 9, 2008
    Messages:
    62
    Likes Received:
    1
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Home Page:
    Thanks, It will help in writing the code.
     

Share This Page