How to parse string with hours greater than 24 to TimeSpan?

If you’re certain that the format will always be “HH:mm” then try something like this:

string span = "35:15";
TimeSpan ts = new TimeSpan(int.Parse(span.Split(':')[0]),    // hours
                           int.Parse(span.Split(':')[1]),    // minutes
                           0);                               // seconds

Leave a Comment