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.
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.
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.
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.