Microsoft Graph - Custom attribute - datetime format

juni dev 336 Reputation points


I need to create a custom attribute in MSGraph to store updatedDateTime
I would like to keep it similat to the existing createdDateTime which is like this:"2022-09-08T16:19:53+00:00"

Since my custom attribute updatedDateTime will be computed from Datetime.Now() and it must be a string,
I used DateTime.Now.ToUniversalTime() but It gives the datetime in this different form: "2022-11-06T21:52:39.331382Z"

What format must I force to have it similat to createdDateTime?


Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,124 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 114K Reputation points

    If there is no corresponding standard format, then try a custom one: DateTime.UtcNow.ToString("yyyy'-'MM'-'dd'T'hh':'mm':'sszzz") or DateTime.Now.ToString("yyyy'-'MM'-'dd'T'hh':'mm':'sszzz").

0 additional answers

Sort by: Most helpful