Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert string to time span

Tags:

c#

I need to convert my string to time span in c#, Here is my string 52:13:27.0000000 When I am trying Timespan.parse it is giving error

The TimeSpan could not be parsed because at least one of the numeric components is out of range or contains too many digits.

Please help! Thanks

like image 802
Deepika Thakur Avatar asked Feb 08 '23 21:02

Deepika Thakur


1 Answers

TimeSpan.Parse() accepts Days:Hours:Minutes:Seconds:Miliseconds if you want to have more than 24 hours, you have to add a day.

In your specific case, it should be something like the following:

TimeSpan.Parse("2:04:13:27.0000000");
like image 52
Mehrdad Kamelzadeh Avatar answered Feb 10 '23 12:02

Mehrdad Kamelzadeh