Hi i need to calculate the time between Login and Logout in asp.net using c#
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Krishna GaradRank #191 · 12.8K reputationPosted Mar 10, 2012, 1:33 AM EST
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
selvi subramanianRank #2,007 · 723 reputationPosted Mar 19, 2012, 4:32 AM EDT
Krishna GaradRank #191 · 12.8K reputationPosted Mar 19, 2012, 5:19 AM EDT
selvi subramanianRank #2,007 · 723 reputationPosted Mar 29, 2012, 3:57 AM EDT