In The YouTube v3 Developer API, when retrieving the video duration it's returned in ISO 8601 format.
How can I parse this as a DateTime object in C#?
Here's an example: PT5M58S
In The YouTube v3 Developer API, when retrieving the video duration it's returned in ISO 8601 format.
How can I parse this as a DateTime object in C#?
Here's an example: PT5M58S
TimeSpan ts = XmlConvert.ToTimeSpan("PT5M58S");
Best option is to convert to a TimeSpan instead of a DateTime.
From the MS docs on TimeSpan (https://msdn.microsoft.com/library/system.timespan):
Represents a time interval.