Custom DateTime format

What is the DateTime format "2011-09-12T10:28:55Z"? How can I get it using ToString ()? I have not received any information in Microsoft docs about this. Nothing like this.

+1
source share
2 answers

You can get this using ToString with:

var text = date.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'",
                         CultureInfo.InvariantCulture);

I do not think that the standard date / time format that covers this is unfortunately.

Of course, if it is not UTC date / time, then it will be a lie (which means the “Z” bit). You can call DateTime.ToUniversalTime()to convert it, of course.

+4
source

All Articles