Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

When user login in my website i have to insert logindate and logintime in database.


and when user logout from website i have to modify the status as user logged out.


but the problem is when i am update the status based on logindate and logintime

i am catching the logintime in sessions but it does not store the milliseconds.

when i am inserting the logintime in database it stores the milliseconds also

but when i am updating my logintime does not match with that because of milliseconds problem


how to catch milliseconds in C#.net

please help me
Posted
Comments
[no name] 5-Dec-11 23:58pm    
can you share us your code and your desired output?
Member 7932936 6-Dec-11 3:44am    
Session["logintime"]=convert.todatetime((obj.logintime).tostring());

1 solution

When you store the login time in teh Session, are you converting it to a string? If so, then that is your problem - the default ToString implementation does not return the millseconds. Instead, store it as a DateTime directly, and cast it back when you retrieve it. That way, it does not lose any information.
See MSDN: http://msdn.microsoft.com/en-us/library/ms178581.aspx[^]
 
Share this answer
 
Comments
Member 7932936 6-Dec-11 4:00am    
thanks alot

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