PM. PM. - 7 months ago 70
C# Question

Datetime conversion with milliseconds and timezone

I found many questions about parsing datetime from various formats, but not able to find the solution to my problem of converting datetime string with milliseconds and timezone both.

My input is like


And format of this is like:


I tried DateTime.ParseExact and DateTimeOffset.ParseExact with/without
but nothing worked.

Found similar question Here but it's not working for me.

I get the exception

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll


Change the format to yyyyMMddHHmmss.fffzzzzz, acording the documentation, the "zzz" custom format specifier represents the signed offset of the local operating system's time zone.