1

In my project I'm sending requests to an api. One of the parameters that I send is datetime. Its format should be like this 2016-05-15T00:00:00.000+0300. I'm taking exactly this as a string and convert it to datetime with this code var startDate = DateTime.ParseExact("2016-05-15T00:00:00.000+0300", "yyyy-MM-dd'T'HH:mm:ss.fffzzz", System.Globalization.CultureInfo.InvariantCulture); However when I used this, the output becomse 2016-05-15T00:00:00.000+03:00. How can I turn this into a datetime without putting colon in gmt part?

afc
  • 56
  • 6
  • You are converting to `DateTime`. Where do you see the format you describe? – Patrick Hofman Aug 09 '17 at 07:01
  • Here. https://gop.epias.com.tr/gop-servis/technical/tr/#_gün_Öncesi_uygulaması_Örnek_mesaj_yapısı. You can see it by scrolling down. – afc Aug 09 '17 at 07:27
  • The pair of single quote marks between "T" treats individual character as unchanged literal (those quotes not shown after parsing). See [here](http://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Roundtrip) for more info. – Tetsuya Yamamoto Aug 09 '17 at 07:36
  • Unfortunately, the zzz format specifier always inserts a colon after the time zone hours, and I'm not aware of a way to change it. As a workaround, you can use the zz specifier, which adds the hours only, and add 00 as a literal. However, this will be inaccurate for time zones containing a fraction of an hour. – SBS Aug 09 '17 at 07:48

0 Answers0