-4

Im consuming a REST api that returns a datetime in the format 2022-09-08T00:21:32.712+03:00 this translates to 08/09/2022 00:21. How do I convert a date value say 08/09/2022 00:21 to the format 2022-09-08T00:21:32.712+03:00 in C#? I have tried below cord without success

    string NIRA_CREATEDDATE_FORMATED = NIRA_CREATEDDATE.ToString("yyyy-MM-dd'T'HH:mm:ss.fffffff'Z'");
Nelson Kibet
  • 41
  • 1
  • 1
  • 6

1 Answers1

0

That is an ISO 8601 format. C# will output it if you use the "o" format.

DateTime.Now.ToString("o")

Note that you'll likely see a higher level of precision than the one you've provided, but that won't typically matter.

StriplingWarrior
  • 151,543
  • 27
  • 246
  • 315