C# Method to sum hh:mm data ???
Asked Answered
F

1

5

I want a method that will sum data that is string in the format hh:mm (time hours and minutes)

0:15 + 0:15 = 0:30

Flong answered 20/5, 2010 at 6:49 Comment(0)
A
16

Convert the strings to TimeSpans and then call the .Add method.

TimeSpan s1 = TimeSpan.Parse("0:15");
TimeSpan s2 = TimeSpan.Parse("0:45");

TimeSpan s3 = s1 + s2;

// not tested; should work.

Ref: http://msdn.microsoft.com/en-us/library/system.timespan.aspx

Allium answered 20/5, 2010 at 6:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.