Basically, what you need to do is put those time values into DateTime
structures. Once you have your two DateTime
variables, just subtract them from one another - the result is a variable of type TimeSpan
:
DateTime dt1 = new DateTime(2010, 5, 7, 13, 45, 26, 836);
DateTime dt2 = new DateTime(2010, 5, 7, 14, 24, 18, 473);
TimeSpan result = dt2 - dt1;
string result2 = result.ToString();
TimeSpan has a ton of properties that get sets - the difference in all sorts of units, e.g. milliseconds, seconds, minutes etc. You can also just do a .ToString()
on it to get a string representation of the result. In result2
, you'll get something like this:
00:38:51.6370000
Is that what you're looking for?