DateTime StartTime = DateTime.Now.ToLocalTime();
DateTime EndTime = DateTime.Now.ToLocalTime();
string dt = EndTime.Subtract(StartTime).ToString().Split('.')[0].ToString();
button1.Text = dt;
starttime = session["logintime"].tostring();
endtime=currenttime...
i have error in retriving the starttime values(ie,session)
if i run this code...it displays the starttime value like 12:00:00
i need this type of output
StartTime:8/7/2010 3:31:16 PM
EndTime:8/7/2010 3:32:00PM
OutPut:
dt=00:00:44
Loading
Kunal VaishyaPosted Apr 24, 2012, 1:51 AM
You can also use session like this to store date time variable
Store DateTIme
/////////////////////////
DateTime dt;
dt = DateTime.Now();
//////////////////////////////
Fetch Date Time
DateTime dt =
(DateTime)Session["Dtval"];
After you can get diffrence
MohanRaj CPosted Apr 24, 2012, 1:53 AM
Kunal VaishyaPosted Apr 24, 2012, 1:41 AM
dt.ToString("MM/dd/yyyy hh:mm:ss")
Or
Refer This
Other Reference
http://www.csharp-examples.net/string-format-datetime/