Click here to Skip to main content
15,914,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi All ,
Please help me out,
how to get difference of user login and logout time and show it in some other textbox?

the thing is login time should automatically load in the textbox when we click on button login and later when we click on button logout at that moment I want current time to be loaded in logout textbox and difference to be displayed in other textbox.....
Posted
Updated 10-Dec-09 17:53pm
v2

1 solution

make a global datetime variable and set it when the user is login successfully and when the user logout get the difference between the current datetime and the variable you set it in the beginning

DateTime loginDate = new DateTime();
double  sessionHours = (DateTime.Now - loginDate).TotalHours;

You can check the other data you can retrieve like days , minutes , seconds and etc

Hope i could help
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900