问题
What's the DateTime format "2011-09-12T10:28:55Z"
?
How can I get it using ToString()?
I didn't get any information in Microsoft's documents about it. Nothing similar like this.
回答1:
You can get that using ToString with:
var text = date.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'",
CultureInfo.InvariantCulture);
I don't believe there's a standard date/time format which covers this, unfortunately.
Of course, if it's not already a UTC date/time then it'll be lying (that's what the 'Z' bit means). You can call DateTime.ToUniversalTime()
to convert it, of course.
来源:https://stackoverflow.com/questions/10581487/custom-datetime-format