Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert ISO 8601-formatted time period to ticks / milliseconds

Is there a built-in way in .NET 3.5 to convert an ISO 8601 period into a .NET TimeSpan / ticks / milliseconds?

like image 298
yas4891 Avatar asked Aug 18 '10 11:08

yas4891


People also ask

Does ISO 8601 have milliseconds?

ISO 8601 represents date and time by starting with the year, followed by the month, the day, the hour, the minutes, seconds and milliseconds. For example, 2020-07-10 15:00:00.000, represents the 10th of July 2020 at 3 p.m. (in local time as there is no time zone offset specified—more on that below).

What is Z in ISO 8601 date format?

Z is the zone designator for the zero UTC offset. "09:30 UTC" is therefore represented as "09:30Z" or "T0930Z". "14:45:15 UTC" would be "14:45:15Z" or "T144515Z". The Z suffix in the ISO 8601 time representation is sometimes referred to as "Zulu time" because the same letter is used to designate the Zulu time zone.


1 Answers

XmlConvert.ToTimeSpan seems to have been around forever and does exactly what you want.

like image 197
Mac Avatar answered Oct 18 '22 10:10

Mac