-3

I need to know which datetime.TryParseExact function will support for format like

2021-11-21 11:34:45.234567+0000

in C#.Net? I am getting above datetime format in my source file.

I have tried "yyyy-MM-dd HH:mm:ss.ffffffzzz", But doesn't work. Thanks.

Dmitry Bychenko
  • 180,369
  • 20
  • 160
  • 215
ramu
  • 121
  • 1
  • 13
  • `yyyy-M-d H:m:s.FFFFFFzzz`? To be on the *safe side*: we have no clue if month, day, hour etc. have *leading zeroes* (that's why I put `M` instead of `MM` etc.). – Dmitry Bychenko Nov 22 '21 at 12:01

2 Answers2

0

You're missing the timezone specifier: K

Try "yyyy-MM-dd HH:mm:ss.ffffffzzzK"

Benedict H.
  • 129
  • 7
0

try like this

Example

    string format = "yyyy-MM-dd HH:mm:ss.ffffff zzz";
    var dt = DateTime.Now.ToString(format);