Hi i need to calculate the time between Login 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.
selvi subramanianPosted Mar 29, 2012, 7:57 AM
Krishna GaradPosted Mar 19, 2012, 9:19 AM
selvi subramanianPosted Mar 19, 2012, 8:32 AM
Krishna GaradPosted Mar 10, 2012, 6:33 AM
While login get the current time like bellow
DateTime _starttime = DateTime.Now;//keep this time in session variable
Sessio["Start"]=_starttime;
Next when user log out
TimeSpan ts;
DateTime _starttime=Convert.ToDateTime(Sessio["Start"]);
ts = DateTime.Now.Subtract(_starttime);
double _ttaken = ts.TotalSeconds;//here u can get minutes,hours,seconds,days