|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Format a TimeSpanHi,
I'd like to convert a TimeSpan value to a String - but without seconds (e.g. "12:01" for 12 hours and one minute). Is there a way to use String.Format() or other functions to do this? Thanks, Guido Guido Kraus wrote:
> Hi, You could convert to a DateTime and use that class's extensive> > I'd like to convert a TimeSpan value to a String - but without seconds (e.g. > "12:01" for 12 hours and one minute). Is there a way to use String.Format() > or other functions to do this? formatting available in ToString: TimeSpan ts = new TimeSpan(12, 1, 14); Console.WriteLine (ts.ToString()); DateTime dt = new DateTime(ts.Ticks); Console.WriteLine (dt.ToString("hh:mm")); output: 12:01:14 12:01 but maybe there is a cleaner way. -- Larry Lard replies to group please |
|||||||||||||||||||||||