I'm thinking this should be easy, but I can't figure out how to format a TimeSpan object the way I'd like it displayed.
I'd like to display as hh:mm:ss - that is, without the milliseconds. Can anyone help me out?
Thanks,
Mike
Printable View
I'm thinking this should be easy, but I can't figure out how to format a TimeSpan object the way I'd like it displayed.
I'd like to display as hh:mm:ss - that is, without the milliseconds. Can anyone help me out?
Thanks,
Mike
FWIW, this is the simplest I could come up with, this is in C#
PHP Code:timeSpan.ToString().Substring(0, timeSpan.ToString().LastIndexOf("."));
this?
if not, sorry.VB Code:
dim tm as timespan . . . string.format("{0}:{1}:{2}",tm.hours,tm.minutes,tm.seconds)
That kind of works, but I (or my users I should say) want it formatted with leading zeros, if need be. Also (this would be easy to add to your code), number of days should be part of the result. This is why I used LastIndexOf, instead of IndexOf.
Thanks,
Mike