Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all can anyone please tell me how to get stopwatch.start() time in asp.net
thanks in advance
Posted
Comments
Orcun Iyigun 22-May-13 9:03am    
Cant you just use the DateTime.Now right after your StopWatch.Start() method?
int hour = DateTime.Now.Hour;
int minute = DateTime.Now.Minute;
int second = DateTime.Now.Second;

1 solution

Stopwatch.Start() starts the stopwatch.
To get the time elapsed you would need to access Elapsed property. Elapsed property returns the Timespan Type. Which you can use to get the value in different formats i.e. Days, Seconds, Milliseconds.

C#
Stopwatch watch = new Stopwatch();
watch.Start();
//call some operation/method
Timespan ts = watch.Elapsed;
int ms = ts.Seconds;


Thanks
- HTH
Nilesh
 
Share this answer
 
Comments
Orcun Iyigun 22-May-13 9:06am    
He is not asking the elapsed time. He is asking to know when did the stopwatch's start time method fired?

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