Hi i need to calculate the time between Login in the id and Logout in asp.net using c#
Hi i need to calculate the time between Login and Logout in asp.net using c#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mahesh ChandPosted Mar 10, 2012, 10:48 PM
SenthilkumarPosted Mar 10, 2012, 11:07 AM
After user logged in into the application (after entering user id and password then click on the button) you can store the logged in time of the user.
Session["LoggedInTime"] = DateTime.Now.ToString();
When the user logged out the application (you may have log out button) then you can get the current time
DateTime.Now
If you want to calculate the time difference between log in and log out then you have to subtract the current time minus session stored time.
DateTime dtLogin = (DateTime) Session["LoggedInTime"].ToString();
DateTime dtLogout = DateTime.Now;
DateDiff (DateInterval.Minute, dtLogin , dtLogout )
There you will get the time difference in minutes.
Mahesh ChandPosted Mar 10, 2012, 7:37 AM
If you do not know how to use a session in ASP.NET, please search this site for Session in ASP.NET.
Krishna GaradPosted Mar 10, 2012, 7:25 AM