How to parse the datetime in millisecond for "20160803T0509+0100". I cannot change the input datetime format as I am receiving by client data file.
Client is using as a system local server time in UTC iso 8601 with offset
I am useing the simple function
Console.WriteLine(Convert.ToDateTime("20160803T0509+0100"));
Error:
String was not recognized as a valid DateTime.
我认为+0100
是针对时区偏移量而不是毫秒
var dateTime= DateTime.ParseExact("20160803T0509+0100", "yyyyMMddTHHmmzzz", CultureInfo.CurrentCulture);
使用DateTime.ParseExact
代替
DateTime result = DateTime.ParseExact("20160803T0509+0100", "yyyyMMddTHHmm+ssff", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None);
只需使用这个
DateTime dt = DateTime.ParseExact("20160803T0509+0100", "yyyyMMddTHHmmzzz", CultureInfo.InvariantCulture);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.