I have got the following code:
DateTime start = DateTime.Now;
Thread.Sleep(60000);
DateTime end = DateTime.Now;
and I would like to calculate the difference in minutes between start and end. How am I supposed to do it? For the example above, the result should be '1'.
Thanks in advance!
I think a more elegant way of doing it would be by using the Stopwatch-Class
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With